0

This code compile succesfully (in visual studio),but there are some warnings like

source.cpp(7): warning C4068: unknown pragma

warning C4081: expected 'identifier'; found 'string'

#include <stdio.h>

#pragma aux __my "_*"           \
       parm routine [eax edx]               \
       value struct struct caller [ ] \
       modify [eax edx];



int __pragma("__my")   test(int a, int b, int c, int d, int e){

    return a * 1 + b * 2 + c * 3 + d * 4 + e * 5;
}

int main(){
    printf("test\n");
    int x = test(1, 2, 3, 4, 5);
    printf("X is %d\n", x);
    return 0;
}

It should change the calling convention, but nothing happend.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
lukas kiss
  • 381
  • 2
  • 15
  • 1
    Really important thing to know about `#pragma`: this is a compiler specific extension. It may not be supported by your compiler, and if it isn't the compiler is **allowed to silently discard it**. That " unknown pragma" message is a kindness. It might be supported and work very, very differently than you expect it to if you're porting code from another tool chain. If you see any `pragma` in unfamiliar code, research the pragma and how your tool chain supports it before using the code. – user4581301 Sep 20 '16 at 22:27
  • I thought the warning was self explanatory. Visual Studio has no clue what #pragma aux is supposed to do, so it doesn't do anything. – user253751 Sep 21 '16 at 00:25
  • So, it is there another method to change calling convetion ? I need it for hooking and i dont want to write naked function with own assembler. – lukas kiss Sep 21 '16 at 06:41
  • The usual `__cdecl`, `__stdcall`, and `__fastcall` don't cover your usecase? – user4581301 Sep 22 '16 at 00:23
  • No, because i hook function, which has special calling convetion. – lukas kiss Sep 28 '16 at 19:43

0 Answers0