Menu

#2 segfault registering functions returning pointer

open
nobody
None
5
2004-07-21
2004-07-21
Furgas
No

Registering following C function:

char* test( int i )
{
return strdup("bleh");
}

like this:

CLU_Init();

CLU_RegisterFunction( "test", "char*", "int", CLU_CDECL,
CLU_CAST( test ) );

results in:
Program received signal SIGSEGV, Segmentation fault.
0x10003eba in CaLua!CLU_Init () from
/cygdrive/c/WINDOWS/CaLua.dll
in the line containing CLU_RegisterFunction.

Instead char* there can be pointer to any type or
structure, it's alwyas crashing. I'm using cygwin
environment. How can I pass some string (char*) from C
function to LUA script?
It's working ok when returning simple int for example.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB