This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FW: Mixing C/C++ code


Robert Wong wrote:

> Also, I'm a bit unclear on how the: extern "C" / extern "C++" notation
> works. If I am using g++ to compile both my C and C++ code...when and which
> of these should I use? Also, I read somewhere that I shouldn't use these
> externs if I'm on a solaris machine, is that right?

extern "C" defines a function with C linkage, so it is visible across
languages.  It's the standard way to do that.  If you are using gcc/g++
on Solaris, as far as I know it should work the same as on any other OS.
It's conceivable that Solaris linker knows things which would permit
inter-language linking without extern "C."  Unless you find an expert on
inter-Solaris compatibility (given there are several incompatible
Solaris architectures), if this is not a crucial subject of your
project, you should avoid it.
C++ linkage supports over-loaded functions, C linkage doesn't.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]