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: what is the use of extern "c"


On 21 January 2013 15:17, Tim Prince wrote:
> On 1/20/2013 10:47 PM, horseriver wrote:
>>
>>
>>     what is the use of extern c within a declaration?
>>
>>
>>
> extern "C" basically shuts off C++ symbol mangling (and facilities which
> depend on it), so as to facilitate linking with C and with languages such as
> Fortran which support C interoperability.

And says to use C calling conventions, because there's no guarantee
C++ uses the same ones (though with GCC it does.)

>  The definition seems rather
> loose; we frequently see reference operators used even though their
> compatibility with C is doubtful.

That's perfectly well-defined. A C program would be able to link to
such a function and e.g. take its address. It just won't be able to
call it (correctly) because it can't pass it a reference.


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