The __stdcall and __cdecl calling conventions states that the functions names must be preceded by an underscore:
C (__cdecl)
The same constraints apply to the 32-bit world as in the 16-bit world. The parameters are pushed from right to left (so that the first parameter is nearest to top-of-stack), and the caller cleans the parameters. Function names are decorated by a leading underscore.
__stdcall
This is the calling convention used for Win32, with exceptions for variadic functions (which necessarily use __cdecl) and a very few functions that use __fastcall. Parameters are pushed from right to left [corrected 10:18am] and the callee cleans the stack. Function names are decorated by a leading underscore and a trailing @-sign followed by the number of bytes of parameters taken by the function.
I have compiled the following code in Visual C++ (The source file had a .c extension, so I guess the source file was compiled as a C file):
void __stdcall stdcallFunction(int i)
{
int j = 12345;
}
void __cdecl cdeclFunction(int i)
{
int j = 12345;
}
int main()
{
stdcallFunction(123);
cdeclFunction(123);
return 0;
}
I have noticed that the function names inside the compiled object file did not have a leading underscore:
Is the leading underscore for the function names for the __stdcall and __cdecl calling conventions optional?
