[Effective-cpp] Item 34: Understand How to Combine C++ and C in the Same Program.

Adrian Fagg AdrianF at evaluategroup.com
Fri Jun 6 04:00:48 EDT 2003


> -----Original Message-----
> From: David Sykes [mailto:davids at revolution.co.uk]

> extern "C" function ( type parameter ); // The name of this 
> function will 
> not be mangled.
> 
> Multiple functions can be grouped, and the __cplusplus 
> definition utilised 
> so that the directives will compile for C as well as C++
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
>   void function1 ( type parameter );
>   void function2 ( type parameter );
>   void function3 ( type parameter );
> #ifdef __cplusplus
> }
> #endif

Can anyone settle a confusion in my mind?

I recall that the above was going to be not the way to do it according to
the standard (as it was coming together at the time). I was under the
impression that extern "C" was going to be required on each function
declaration separately.
Not that I've had cause to use it since hearing that and neither can I see
why that change was made (if it was).

Regards,

Adrian

Work: mailto:adrianf at evaluategroup.com
Home: mailto:adrian.fagg at ntlworld.com

Pretty pictures: http://homepage.ntlworld.com/rbyadf/ 


DISCLAIMER: The contents of this e-mail are confidential and are intended
for the individual or entity named in the e-mail address. If you are not the
intended recipient (or their designated representative), you should notify
the sender immediately and delete the e-mail and any attachments. All
information contained in this e-mail is private and confidential. 

All reasonable precautions have been taken to ensure no viruses are present
in this e-mail. But as we cannot accept responsibility for loss or damage
arising from the use of this e-mail or attachments we recommend that you
subject these to your own virus checking procedures prior to use. 




--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---



More information about the Effective-cpp mailing list