lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Still, Enno's suggestion on a #define that would be used for the "c++ only, please" people sounds like a good one. There's really no excuse for making extra hurdles for newcomers and this is one of the most common. As we all know..!

-ak


RLake@oxfam.org.pe kirjoittaa torstaina, 12. kesäkuuta 2003, kello 19:02:

If more people ask, then probably because it's so uncommon. Make and
other
build tools certainly wouldn't use the c++ compiler unless you force
them
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.