delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/08/03/20:01:36

From: marcus AT bighorn DOT dr DOT lucent DOT com (139a80000-HallMDR313237x10)
Subject: Re: linking gcc & vc++ object files
3 Aug 1998 20:01:36 -0700 :
Message-ID: <199808031440.IAA08150.cygnus.gnu-win32@chorus.dr.lucent.com>
Reply-To: "139a80000-HallM(DR3132)37x10" <marcus AT bighorn DOT dr DOT lucent DOT com>
To: dyoung AT vviuh221 DOT vvi DOT com, gnu-win32 AT cygnus DOT com

David Young asks:

> We are linking object files generated by gcc and object files  
> generated by vc++ on Windows-NT. In order to get object files  
> generated by gcc to link with object files generated by VC++ we have  
> to append a "@n" suffix (n seems to be always a multiple of 4) to the  
> function names (in the gcc related source files) whos object  
> definition is in the files generated by VC++. That's because the VC++  
> generates function symbols in object files with a "@n" suffix. Note,  
> this has nothing to do with C++ name mangling, all function  
> definitions are wrapped in extern "C" {} ; this is an ANSI-C related  
> issue.
> 
> QUESTION: What is the "@n" all about?

This is just the first hurdle...

The @nn suffix means that the routine is compiled for "stdcall" calling 
procedures.  That is, the callee pops the arguments off of the stack.  The 
number after the `@' is the number of bytes that are popped off of the stack.

The other option (without the `@' suffix) is a caller-pops convention "cdecl"
type.  Depending on how various flags are set for VC++, it will default to
one or the other standards.  You can force a routine to be treated (either
in a function definition or external declaration) a particular way by adding
"stdcall" or "cdecl" to the function type specifier.  You really need to
make the functionality match, not just the name.

So, if you declare a function thusly:

stdcall int func(int a, char *b) { /* some code */ }

gcc should generate a callee pops function popping 8 bytes of arguments from
the stack named "func AT 8".

--
marcus hall
-
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".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019