lua-users home
lua-l archive

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


Unfortunately I can't really accept that solution as the
necessity for it is the exact problem I wished to address.
Furthermore, you may notice that

 #ifndef LUA_API
 #ifdef __cplusplus
 #define LUA_API extern "C"
 #else
 #define LUA_API extern
 #endif
 #endif

is perfectly valid C code, which completely eliminates the
need for any C++ specifics, and would keep the issue in
question from ever arising again. There really isn't any
benefit in not writing a header like this, so why not?

27.9.2004 kello 19:02, David Burgess kirjoitti:

  This topic has been discussed before and this is the
designated
> solution.
>
> db
>
> On Mon, 27 Sep 2004 16:57:23 +0100, simon_brown@scee.net
> <simon_brown@scee.net> wrote:
>> 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
_____________________________________________________________________
For super low premiums ,click here http://www.dialdirect.co.za/quote