lua-users home
lua-l archive

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


As you mention, Lua is a C library, so it's not unreasonable that 
C++-specific code is left out of the Lua headers.

I've been cleanly including Lua in C++ headers by wrapping the include 
directives as follows:

extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
} // extern "C"

I guess if you wanted to be even cleaner you could put these contents into 
a "lua.hpp" file and include that in your project.

Simon Brown
Sony Computer Entertainment Europe
http://www.scee.com

lua-bounces@bazar2.conectiva.com.br wrote on 27/09/2004 16:41:04:

> I love the language, but whenever I install Lua on a
> machine I need to make an alteration to the header file.
> 
> The following section allows C programs to use Lua
> functions if the Lua libraries are compiled in C.
> 
> /* mark for all API functions */
> #ifndef LUA_API
> #define LUA_API      extern
> #endif
> 
> It works for C++ only if the libraries are compiled in C++.
> To get both C and C++ programs working with the C library,
> I change that section of the lua.h header to the following:
> 
> /* mark for all API functions */
> #ifndef LUA_API
> #ifdef __cplusplus
> #define LUA_API      extern "C"
> #else
> #define LUA_API      extern
> #endif
> #endif
> 
> Now it works beautifully and transparently, but isn't quite
> standard. I wonder... could this possibly be made the
> standard for lua.h in future releases of lua?
> _____________________________________________________________________
> For super low premiums ,click here http://www.dialdirect.co.za/quote

> ForwardSourceID:NT000078B6 


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster@scee.net

This footnote also confirms that this email message has been checked
for all known viruses.

**********************************************************************
 SCEE 2004