It tells you to specify cdecl calling conventions on one page,
specifying how to do it with GNU GCC and something else, but fails to
mention that is highly Windows specific.
Actually, it's i386-specific. [Which is almost as bad, but still]
"cdecl" (and "_cdecl", "__cdecl", "__stdcall", etc), as the name of a
"calling convention", is a Microsoft extension which is supported for
x86 processors other than the i386, including at least some of the
IA-16 processors that preceeded the 386 and the various IA-32 and now
AMD64 / EMT processors that succeeded it.[1]
It was also supported on non-x86 processors back when Microsoft
shipped Windows for non-x86 systems (other than Itanium).[2] The
specifics of register use in the various calling conventions differed
for non-x86 processors, of course, but the calling-convention
keywords were still supported, and the convention specified by
__cdecl still differed from that specified by __stdcall.
GCC happens to describe its "cdecl" and "stdcall" attribute
extensions as 386-specific,[3] but the GCC documentation is not a
definitive history of how and where particular extensions to C have
been used.
The "cdecl calling convention" is an extension provided by certain
implementations. It is incorrect to claim that it is specific to
Microsoft Windows (though that is where it is predominantly found) or
to the i386 (despite poor wording in the GCC documentation).
1. See for example
http://blogs.msdn.com/oldnewthing/archive/2004/01/02/47184.aspx.
2. See for example "/Gd, /Gr, /Gz (Calling Convention)" in the
October 2001 MSDN Library Collection.
3.
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function Attributes
--
Michael Wojcik (e-mail address removed)
The antics which have been drawn together in this book are huddled here
for mutual protection like sheep. If they had half a wit apiece each
would bound off in many directions, to unsimplify the target. -- Walt Kelly