[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: Daniel Rall <dlr_at_collab.net>
Date: 2007-03-22 22:45:29 CET

On Thu, 22 Mar 2007, Garrett Rooney wrote:

> 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.

svn_wc_private.h should have the extern "C" markup.

  • application/pgp-signature attachment: stored
Received on Thu Mar 22 22:45:50 2007

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