because I want to compile the code as C++ not C. And I get:

vm/neko.h:281: error: expected ‘,’ or ‘...’ before ‘this’

because Neko is using 'this' as an identifier, but in
C++ it is a keyword. Fixed that, then got this:

Oops, there was one remaining :)

vm/alloc.c:43: error: redefinition of ‘_value* val_null’
vm/neko.h:251: error: ‘_value* val_null’ previously declared here

vm/alloc.c:43:
EXTERN value val_null = (value)&t_null;
vm/neko.h:251:
EXTERN value val_null;

The latter code is wrapped in extern "C" using C_FUNCTION_BEGIN.
Also EXTERN is #defined as nothing.

I think this is wrong in C++, and suspicious in C.
To declare, but not define, a variable, you MUST use 'extern',
and to define it .. you must not ;(

I changed IMPORT to be 'extern' and got a different error:

Yes this is a different between C and C++.

vm/alloc.c:43: warning: ‘val_null’ initialized and declared ‘extern’

The problem is that, in alloc.c, val_null is ALWAYS an EXPORT.
You cannot import a symbol you're defining. So I changed it to:

EXPORT value val_null = (value)&t_null;

in vm/alloc.c and the problem went away. So I think this is
a bug .. even though it works in C :)
>
The general rule, I think, is: in a *.c file, everything
should either be static, or EXPORT, never EXTERN.
EXTERN is only needed in header files, where it must
map to EXPORT when you're compiling and linking the library involved, and IMPORT when you're using it
from the mainline or other library (to get the declspec
stuff right on Windows).

Yes it makes sense, but I prefer to make some small changes for variables only since they're only causing the problem.

#define VEXTERN extern EXTERN

then in neko.h :  VEXTERN val_null;


Another problem is this:

vm/alloc.c:80: error: invalid conversion from ‘void*’ to ‘char*’

Fixed 2 of them.

which is easily fixed by just adding an explicit cast. C allows void* to cast to anything implicitly, C++ does not.
Similarly here:

vm/alloc.c:243: error: invalid conversion from ‘void (*)(_value*)’ to
‘void*’
vm/alloc.c:243: error:   initializing argument 3 of ‘void
GC_register_finalizer(void*, void (*)(void*, void*), void*, void
(**)(void*, void*), void**)’

So first casting to void * , then casting to GC_warn_proc ?
I fixed all that, try and tell me.

Nicolas

---
Neko : One VM to run them all

Reply via email to