[cfe-dev] what does __attribute__((__stdcall__)) really mean?

Charles Davis cdavis at mymail.mines.edu
Wed Oct 12 20:49:47 PDT 2011


On Oct 12, 2011, at 9:26 PM, Philip Ashmore wrote:

> 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






More information about the cfe-dev mailing list