what does __attribute__((__stdcall__)) really mean?

Hi there.

I've got a library that uses the stdcall calling convention with some functions, but there are problems.

1. gcc doesn't like __attribute__((__stdcall__)) in some contexts and complains that "warning: ‘__stdcall__’ attribute ignored [-Wattributes]".

If I change this to __attribute__((ms_abi)) the warnings disappear.

clang doesn't warn about this, leading me to conclude that it can do this where gcc cannot.

Should I define a STDCALL macro and define it differently depending on the compiler?

What should I use if I want to create a library with one compiler that links to a program compiled with the other?

Regards,
Philip Ashmore

Can you give a small code example of what isn't working?

-Eli

Hi there.

I've got a library that uses the stdcall calling convention with some
functions, but there are problems.

1. gcc doesn't like __attribute__((__stdcall__)) in some contexts and
complains that "warning: ‘__stdcall__’ attribute ignored [-Wattributes]".

If I change this to __attribute__((ms_abi)) the warnings disappear.

You must be compiling 64-bit.

clang doesn't warn about this, leading me to conclude that it can do
this where gcc cannot.

Actually, the stdcall attribute has no effect in 64-bit mode. That's why GCC produces the warning.

What should I use if I want to create a library with one compiler that
links to a program compiled with the other?

On 64-bit--nothing. On Win64, both Clang and GCC use the standard Win64 calling convention (ms_abi). Everywhere else, Clang and GCC use the standard Unix convention (sysv_abi). You only need ms_abi if you're actually linking to code that uses that convention and you're not on Windows (but you are on a 64-bit OS).

Chip