are g++ gcc libraries incompatible?
I have a library of homegrown C functions;
I write stuff in C and C++ if I compile the library with g++, then gcc compiled sources won't link and vice versa. is there a way to get round this or do I need to make two libraries, one for gcc and one for g++? |
I don't see enough info in your post to be sure of what you are trying to do, but I have a good guess.
If you want functions that can be called from either C or C++, they must have a C interface. In C++ you use Code:
extern "C" You often need an include file that can declare the C interface and can be included in either C or C++ compiles. Usually that requires something like conditionally #defineing some symbol to be either nothing or "C" so it can be used every place a C interface must be predeclared with extern if including into a C module but with extern "C" if including into C++. Other cases may require two symbols, one for nothing vs. extern "C" { and the other for nothing vs. } |
ahh thanks dude!
this works... Code:
extern "C" { do you happen to know if there's an #ifdef I could use depending on whether it's gcc or g++? then I could put the wrapper in the header file. |
Quote:
Code:
#ifdef __cplusplus |
As a side note, you should link g++-compiled objects using g++, not ld, which if you didn't already know you'd find out sooner or later.
Kevin Barry |
yes, I always use GNU make so it generally works ok
with the implicit rules. |
All times are GMT -5. The time now is 11:13 PM. |