lua-users home
lua-l archive

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


>> I try to use the one.c file from Luiz. It works fine in C mode. When
>> trying in C++ mode, you have several errors like:
>>   lobject.h:581:24: error: uninitialized const 'luaO_nilobject_'
>> both on GCC than on Visual Studio.
>
> This seems to indicate a difference in the way C++ and C handle 'static'
> declarations. The problem seems to be constructions like this:

In c++ "const T obj;" is a definition (with internal linkage) while in
c it is only a tentative definition (with external linkage).
Moreover, in c++ const data *must* be initialized, either by an
explicitly declared constructor or an initializer.  So in c++ "const
TValue obj;" is indeed an error since TValue declares no constructor
(obviously) and the definition of obj does not specify an initializer,
such as ={}.

Bye,
Wim