From: khan AT xraylith DOT wisc DOT edu (Mumit Khan) Subject: re: stdcall 6 Jan 1999 02:28:52 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: rfnum AT www DOT twinux DOT com Cc: gnu-win32 AT cygnus DOT com On Mon, 4 Jan 1999 rfnum AT www DOT twinux DOT com wrote: > When writing a win32 application, how are STDCALL functions handled? > If the windows API expects to pop arguments to a call, how does > egcs handle it? Does it do the 'right' thing? Is there an interface > layer that does it? Is this option available available on other > platforms? They're handled exactly as the GCC documentation suggests. Yes, it mostly does the right thing[1]. I'm not sure what you mean by an interface layer, but see [2] below. And, yes, it's supported under all platforms; why you'd want to use it on any other platform where you don't have to is of course an altogether different issue! [1] There is nasty bug GCC code generation bug with STDCALL (aka WINAPI) routines that causes any function return floats or doubles to return garbage. This is quite a low priority for GCC developers, so unless someone contributes the fix, who knows when it'll get fixed. Unfortunately, this particular bug makes it hard to use GCC to write DLLs for VB, which requires WINAPI/STDCALL calling convention. [2] GCC uses "attributes" to tag a function STDCALL/CDECL etc. See GCC docs for more info. eg., the following function is going to use STDCALL calling convention: int __attribute__((stdcall)) foo (); Since writing the attributes are painful, and since we want to maintain source level compatibility, GCC also predefines __stdcall to expand to the above, and so you can instead write: int __stdcall foo (); Or, you can use IMO the preferred style and use pre-defined macros WINAPI and CDECL (found by including windows.h): int WINAPI foo (); Regards, Mumit - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".