Hello guys,
New to Haxe and hxccp and unsure what the problem is.
I compiled a bunch of Haxe utility classes (logger, config, io etc) to a static library and call it from a Visual Studio 2013 C++ test application.
1. First I had some invalid cast runtime errors in the cpp-generated Haxe Main() itself triggered by some multi-inherited Interface
The error is always in Object.h in CastPtr dynamic_cast:
inline void CastPtr(hx::Object *inPtr,bool inThrowOnInvalid)
{
if (inPtr)
{
mPtr = dynamic_cast<OBJ_ *>(inPtr->__GetRealObject()); //ERROR: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
...
I could apparently get rid of the issue by either using @:unreflective or by transforming the Interface into an 'Abstract' class.
Also tried /vmg and /vmm msvc options and -D dynamic_interface_closures without success.
2. Now I'm having a weird issue in the C++ app main():
int _tmain(int argc, _TCHAR* argv[])
{
hxcpp_set_top_of_stack();
const char *err = hxRunLibrary();
if (err) {
// Unhandled exceptions ...
fprintf(stderr, "Error %s\n", err);
return -1;
}
If no more code in the main() I have no crash.
If I add some code dealing with some ::haxe interface class also used in one of my haxe library classes for a cast operation then I get a invalid cast crash in hxRunLibrary's __boot_all()
eg:
After the hxRunLibrary() line in the main() I create and use a cpp Logger object from my static library, this Logger uses a ::haxe::IMap internally
Then when hxRunLibrary is called:
void Logger_obj::__boot()
{
...
::haxe::IMap tmp1 = ((::haxe::IMap)(tmp)); HX_STACK_VAR(tmp1,"tmp1"); // => BOOM, INVALID CAST
...
}
BTW I've tested this Haxe Logger class in the Haxe Main() of the static library and it seems to work when called from the C++ app via hxRunLibrary()).
What am I doing wrong ?
Is there any hxcpp sample project that does this kind of thing (using a Haxe cpp static library from a VS console application) ?
Thanks,
USam