lua-users home
lua-l archive

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


> Sorry, but IIRC, it's the orther way around. You can compile 
> Lua in two ways. Either you compile Lua as C++ (Lua is valid 
> C++), and then you don't need 
> the extern "C" anywhere. Or, you compile lua as C, and then you'll 
> need the extern "C".  

You are correct, I misspoke.

Lua will compile as either ANSI C or as C++.  By default most compilers
determine the form to compile based on the extension - .c is treated as
ANSI C.  However, you can override this with various command line
switches (e.g. /TP with MSVC).

You just have to be very careful that you're aware what's going on and
that you're consistent.

An error I've made more than once was doing this:

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

In a C++ file that uses Lua, but forgetting that I was compiling Lua as
C++.  Or, conversely, compiling Lua as C++ and accidentally putting the
"extern C" around the include statement from another source file.

Brian