[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: extern "C" ?
- From: "Vijay Aswadhati" <wyseman@...>
- Date: Sun, 14 Sep 2003 14:05:51 -0700
Brian has a point that escaped me completely when this subject was discussed
earlier. C++ name mangling is not portable and hence LUA library compiled
for C++ by Visual C++ for instance cannot be used by an application that
uses Borland compiler (wont link because of name mangling differences).
For what its worth I second Brian's suggestion on handling this in
satisfying all camps and school thought. And concur that Joe Programmer
should not have to modify the source code to make it compile.
Vijay Aswadhati
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Brian Weed
> Sent: Sunday, September 14, 2003 1:41 PM
> To: Lua list
> Subject: Re: extern "C" ?
>
>
> Anyone compiling the lib as C++ is making a mistake. C++
> name mangling is
> not portable, so if they ever switched compilers they would have to
> re-compile the LUA libs just to be able to re-link. If it
> were a C lib, and
> correctly used the #ifdef __cplusplus, it would work accross
> all compilers
> (on the same platform).
> And this is what almost all other libs do (Png, Zip, FreeType, etc...)
>
> However, I can see that this won't change the minds of the people who
> matter, so I therefore endorse this guys suggestion, or something else
> similar like:
>
> #if defined(_cplusplus) && !defined(LUA_CPP)
> extern "C" {
> #endif
>
> So the few people who NEED it to be C++ can define LUA_CPP
>
> But, whatever the solution, Joe Programmer should not have to
> modify the
> source code to make it compile. Libs like this should work
> out of the box.
>
> Brian
>
> ----- Original Message -----
> From: "Jamie Webb" <j@jmawebb.cjb.net>
> To: "Lua list" <lua@bazar2.conectiva.com.br>
> Sent: Sunday, September 14, 2003 3:53 PM
> Subject: Re: extern "C" ?
>
>
> > On Sunday 14 September 2003 18:06, Philip D. Bober wrote:
> > > But if that were in the original files, it wouldn't affect C users
> (because
> > > of the #ifdef __cplusplus), only C++ users.
> >
> > You're missing the point: we might want to compile Lua using the C++
> compiler.
> > You then don't want the externs despite being a C++ user.
> It's only if you
> > compile Lua using a C compiler (or use prebuilt library)
> and your program
> > using a C++ compiler that you need them.
> >
> > A suggestion: how about using a different macro, e.g. #ifdef
> LUA_EXTERN_C...,
> > then people who want the externs can add that their
> makefiles once and
> leave
> > the sources alone, and people who don't want the externs
> won't get them.
> >
> > -- Jamie Webb
> >
> > How to hack a Computer: Step 1: Take axe and...
> >
>
>