lua-users home
lua-l archive

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


In message <5.0.0.25.0.20001013122735.00afbe90@mail.tecgraf.puc-rio.br>, "Anton
io E. Scuri" writes:
> 1) extern "C"
> 
>    If a library is implemented in C, all the headers that export functions 
> must have the extern "C". This is no harmful, not against the ANSI C, and 
> very useful to C++ developers.
> 
>    Lua is implemented in C, but have a special characteristic that compiles 
> as C++ also. So, if we include the extern "C" and compile the library as 
> C++, the exported functions will still have a C declaration. Since every 
> C++ compiler supports this feature I think that Lua headers should contain 
> the extern "C".

No, do not add extern "C" to the interface to a _C_ library.

If you want to use the interface from C++, create a header file of your
own.  Say, "cpplua.h" with the following contents:

extern "C" {
#include "lua.h"
}

(pardon my C++ if I get the details slightly wrong) and include
"cpplua.h" instead of "lua.h".  There's no need (in this case) to
corrupt the C files with C++ code.

djones