Skip to main content
gamedev.net
🔒 Locked

problem binding a function with angelscript.

Started by vicviper 0 replies 850+ views
Original Post
vicviper
vicviper
I am beginning to use Angelscript, so far, it has been running well. But I found a little trouble, that may be a bug (can't think anything else) I have this native C funcion: __cdecl float GetAFloat(void) {return(1.0);} and I bind it this way: RegisterGlobalFunction("float GetAFloat()", asFUNCTION(GetAFloat), asCALL_CDECL); The problem: When I use this funcion in the script, what I gest is just a -1.#IND , I figure it means it's an undefined value. I'm using AngelScript 2.7.0 Thanks in advance
vicviper
vicviper

Ok, problem solved.

it looks like I was placing __cdecl the wrong way when defining the funcion:

the correct way was:

float __cdecl GetAFloat(void);

if defined the other way "__cdecl float GetAFloat(void);" , it looks like it has no effect over the funcion, and the compiler does some kind of optimization, compiling the function with a different, faster calling convention.

Vic

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.