Mail Archives: djgpp/1994/05/03/10:22:19
On Tue, 3 May 1994, Mark Wyman(AH) wrote:
> How do you use .S files with the C++ compiler?
>
> I have some functions written in GAS format that I used fine with
> the C compiler. However, when I switched over to doing C++ I
> can't get the compiler to recognize the assembly functions.
>
> For example, one of my routines is _SetPalette. I included the
> .S file in the makefile (first thing I looked for :) ) and called
> _SetPalette from one of the .cc files. Error came up saying unknown
> identifier. I assembled the .cc file into a .S file to see what it
> was doing and it is trying to call _SetPalette__FlllPC.
>
> Anyone know how to get it to recognize _SetPalette without renaming
> _SetPalette to _SetPalette__FlllPc?
Mark,
You need to use the following convention for prototyping C-compiled
routines to call them from C++ (including GAS routines callable by C):
extern "C" {
ret_type SetPalette(/* args and their types */);
}
I has something to do with the way symbol names are constructed in C
versus C++. Note also that GAS defines _SetPallette, but you call it
SetPallette from C or C++.
Hope this helps,
Ed
/***************************************************************************/
/* Ed Phillips flaregun AT strauss DOT udel DOT edu University of Delaware */
/* Jr Systems Programmer (302) 831-6082 NSS/Software Systems */
/***************************************************************************/
- Raw text -