Internal value of bool?

Started by
1 comment, last by zexee 10 years, 6 months ago

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.

Advertisement

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sorry, it was my mistake. I was actually calling opCmp so equal is 0. Thank you for your answering!

This topic is closed to new replies.

Advertisement