[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: When is the C++ transition needed?

On Thu, Oct 06, 2005 at 09:24:19PM -0400, Nathanael Nerode wrote:
> Brian Carlson wrote:
> >> You must not pass by reference with an extern "C" declaration, because C 
> >> doesn't support that.
> Dan Jacobowitz wrote:
> >Why not?  An extern C definition doesn't mean that it needs to be
> >usable from C.  It just means to use the C calling convention.
> Perhaps because there is no C calling convention for passing by reference?  
> How to pass arguments is part of the calling convention.  :-P  You can pass 
> C++-only objects, certainly, but you have to be able to pass them in a way 
> which is understood in the C calling convention.

That's incorrect.  The C++ ABI uses a defined convention for passing by
reference, and with a different prototype and some care, or from
assembly, you can duplicate the effect.

The primary effect of extern "C" is just disabling mangling.

Daniel Jacobowitz
CodeSourcery, LLC

Reply to: