[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using Lua in a C(++) program
- From: RLake@...
- Date: Thu, 12 Jun 2003 11:02:01 -0500
> If more people ask, then probably because it's so uncommon. Make and
> build tools certainly wouldn't use the c++ compiler unless you force
> to, and why you wanted to do that, I don't know. So why allow that?
Because you might be able to take advantage of C++ features. You might,
for example, be developing on a platform where C++ exception handling
is incompatible with C setjmp()/longjmp() exception handling; compiling
Lua as C++ may avoid problems with callbacks from C++ code. (In fact,
modifying Lua to use exceptions instead of setjmp()/longjmp() is
quite simple, and makes things a bit cleaner.)
> And if you really want to allow it, make sure people are aware of what
> they are doing (making a lib that won't work with plain C), and have
> them explicitly #define a variable (which could then also disable
> the extern "C" part).
Or, perhaps even better, provide a make target that builds C++ librarys
with different names.
I think it would also be nice to distribute a make template for user
projects. I'm sure we all have such things.
> Really. Haven't seen a library in years that didn't have a __cplusplus
> encapsulated extern "C", and I've seen my share.
That's probably because most libraries don't trust themselves to
compile in C++. Kudos to the Lua team for writing clean code.