[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Question on extern "C" logic

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2007-03-22 20:44:13 CET

On 3/22/07, Paul Burba <pburba@collab.net> wrote:
> Recently when Erik added the new private header file svn_wc_private.h I
> noticed he didn't include the extern "C" logic:
> #ifdef __cplusplus
> extern "C" {
> #endif /* __cplusplus */
> #ifdef __cplusplus
> }
> #endif /* __cplusplus */
> Which seems the correct thing to do since these functions are not part
> of Subversion's public API and won't be called by any C++ code. We do
> have the extern logic in all the other include/private header files
> however. Is this necessary for any reason? I don't really care about
> changing this since it seems harmless enough, just want to make sure I
> understand it correctly.

The extern "C" statements are needed for any C header that might be
included by C++ code. If you don't wrap the code in extern "C" then
the C++ code that tries to use it will use C++ name mangling on the
symbols and you'll get a link error. Wrapping everything in extern
"C" blocks tells the C++ compiler to not mangle the symbol names so
everything works out at link time.


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 22 20:44:34 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.