MigPosada
10-08-2011, 01:42 PM
Using dllbind functions similar to this:
// Unreal Script
dllimport final function bool SimActorExists(int actorID);
// C++
__declspec(dllexport) bool SimActorExists(int actorID);
I was finding functions returning true all the time, even if the C++ code was simply doing : { return false; }
Sometimes changing unrelated code fixed the function behavior, but it wasn't a reliable solution.
The issue was completely fixed by changing the C++ function to:
__declspec(dllexport) unsigned int SimActorExists(int actorID);
The documentation on http://udn.epicgames.com/Three/DLLBind.html clarifies returning a bool is actually mapped to unsigned int (32-bit), but the initial example on the same page uses bool in the C++ function.
My guess is the documentation needs to be corrected because returning bool from C++, depending on code, compiler and who-else knows, can result on unexpected behavior.
// Unreal Script
dllimport final function bool SimActorExists(int actorID);
// C++
__declspec(dllexport) bool SimActorExists(int actorID);
I was finding functions returning true all the time, even if the C++ code was simply doing : { return false; }
Sometimes changing unrelated code fixed the function behavior, but it wasn't a reliable solution.
The issue was completely fixed by changing the C++ function to:
__declspec(dllexport) unsigned int SimActorExists(int actorID);
The documentation on http://udn.epicgames.com/Three/DLLBind.html clarifies returning a bool is actually mapped to unsigned int (32-bit), but the initial example on the same page uses bool in the C++ function.
My guess is the documentation needs to be corrected because returning bool from C++, depending on code, compiler and who-else knows, can result on unexpected behavior.