Sign in to follow this  
zexee

Internal value of bool?

Recommended Posts

zexee    118

I am just met trouble of use c++ to access bool value in angelscript. There is no SetArgBool or GetReturnBool, and it said bool is 8bit in the document. So I used *(bool*)GetAddressOfReturnValue() but it turned out wrong.

 

I looked at the memory, it seemed that true is 0 and false is 255 in byte. If so, that is different from c++ tradition (as far as I can remember, in c++ 0 is false and all others are true), and it should be documented or provide set and get function.

Share this post


Link to post
Share on other sites
WitchLord    4677

bool in AngelScript uses the same binary value as in C++. 0 for false and 1 for true (though anything different than 0 will be interpreted as true).

 

 

*(bool*)GetAddressOfReturnValue() should work, as should GetReturnByte().

 

 

What does the script function look like? And did the Execute() method return asEXECUTION_FINISHED? If it didn't return with this value the script function didn't return yet (or an exception was raised) and obviously any return value you try to get will not be what you expect.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this