Steps to run:
- Mac or Linux environment
- Install latest Haxe and HXCPP, dev versions from git
- Copy these three files to a folder
- Add an include/hx folder with the hxcpp headers (hxcpp/include/hx)
- Create an "out" folder
- Compile with
haxe -cp Main.hx -main Main -cpp out
You will get this result (on Mac):
haxelib run hxcpp Build.xml haxe -Dhaxe3="1" -Dhaxe_ver="3.4" -Dhxcpp_api_level="331" -Dsource-header="Generated by Haxe 3.4.0" -I"Main.hx/" -I"/usr/lib/haxe/extraLibs/" -I"/usr/local/lib/haxe/extraLibs/" -I"" -I"/usr/lib/haxe/std/cpp/_std/" -I"/usr/share/haxe/std/cpp/_std/" -I"/usr/local/lib/haxe/std/cpp/_std/" -I"/usr/lib/haxe/std/" -I"/usr/share/haxe/std/" -I"/usr/local/lib/haxe/std/"
Creating /Users/larsdoucet/Development/test/cffi/src/out/obj/darwin64/__pch/haxe/hxcpp.h.gch...
Compiling group: haxe
g++ -Iinclude -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/Users/larsdoucet/Development/git/hxcpp/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=331(haxe) ... tags=[haxe,static]
- src/Main.cpp
- src/Stuff.cpp
Error: ./src/Stuff.cpp:83:54: error: ambiguous conversion for functional-style cast from '::cpp::Function<int (int, int)>' to 'hx::Val' (aka 'cpp::Variant')
if (HX_FIELD_EQ(inName,"CFFI_TraceIII") ) { return hx::Val( CFFI_TraceIII); }
^~~~~~~~~~~~~~~~~~~~~~
/Users/larsdoucet/Development/git/hxcpp/include/cpp/Variant.h:64:14: note: candidate constructor
inline Variant(bool inValue) : type(typeBool), valBool(inValue) { }
^
/Users/larsdoucet/Development/git/hxcpp/include/cpp/Variant.h:293:13: note: candidate constructor
Variant::Variant(const Dynamic &inRHS) : type(typeObject), valObject(inRHS.mPtr) { }
^
1 error generated.
Error: Build failed
Context: I've been getting this error on my CI when trying to build the steamwrap library, but ONLY on Mac and Linux, and only recently (last few months).
Speculation: I think this might be a regression with haxe/hxcpp and clang g++. This error does not occur on windows.
Note: I have no idea if I even got the CFFI prime setup right, as you can see I commented out the actual calling of the function. However, as soon as this mysterious error jumped out at me -- the same one I've been seeing on my CI -- I decided I had my repro case and figured I would just seal it right there.