haxeui / hxWidgets

Haxe externs (and wrappers) for wxWidgets
MIT License
77 stars 22 forks source link

C++ compiler error -- missing conversion from 'long' to 'const Dynamic' #73

Closed perlmonger42 closed 3 years ago

perlmonger42 commented 3 years ago

I'm using:

The error message is:

Error: ./src/hx/widgets/DataViewListCtrl.cpp:232:28: error: conversion from 'long' to 'const Dynamic' is ambiguous

I notice that there is a definition to convert long to Dynamic defined in /usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:

#if !defined(__GNUC__) || (defined(__WORDSIZE) && (__WORDSIZE != 64))
Dynamic(long inVal);
Dynamic(unsigned long inVal);
#endif

I would expect that code to be included, since I'm compiling on a Mac, and would expect !defined(_GNUC_) to be truthy (I don't know how to check, but surely it's using clang?). But I believe it is not being included, because Dynamic(long inVal) is not included in the list of "candidate constructors" listed in the C++ compiler output.

I recognize that this may be an hxcpp issue, but I thought I'd start here. Here's the transcript, though I've left off the long series of complaints about Std.is being deprecated.

Thanks for looking at this. =thom

$ haxelib install hxWidgets
Downloading hxWidgets-1,7,2.zip...
Download complete: 0.25KB in 0.8s (0.2KB/s)
Download complete: 237.09KB in 0.1s (1556.1KB/s)
Installing hxWidgets...
  Current version is now 1.7.2
Done
Installing dependency hxcpp 4.2.1
You already have hxcpp version 4.2.1 installed
$ haxeui create hxwidgets

 Using name from descriptor "descriptors.HxmlFile": "Main"
 Creating haxeui-hxwidgets files for "Main"
    - Skipping "/Users/thom/src/haxeui-getting-started/src"
    - Skipping "/Users/thom/src/haxeui-getting-started/assets"
    - Skipping "/Users/thom/src/haxeui-getting-started/src/Main.hx"
    - Skipping "/Users/thom/src/haxeui-getting-started/assets/main-view.xml"
    - Skipping "/Users/thom/src/haxeui-getting-started/src/haxeui-hxwidgets.properties"
    - Skipping "/Users/thom/src/haxeui-getting-started/hxwidgets.hxml"
$ haxe hxwidgets.hxml
haxelib run hxcpp Build.xml haxe -DABI="-MD" -DNO_PRECOMPILED_HEADERS="1" -DPLATFORM_MAC="1" -DWXSTATIC="1" -Dhaxe="4.2.1" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.201" -Dhaxeui-core="1.2.3" -Dhaxeui-hxwidgets="1.2.3" -Dhaxeui_core="1.2.3" -Dhaxeui_hxwidgets="1.2.3" -Dhscript="1" -DhxWidgets="1.7.2" -Dhxcpp="4.2.1" -Dhxcpp_api_level="400" -Dhxcpp_smart_strings="1" -Dsource-header="Generated by Haxe 4.2.1+bf9ff69" -Dstatic="1" -Dtarget.name="cpp" -Dtarget.static="true" -Dtarget.sys="true" -Dtarget.threaded="true" -Dtarget.unicode="true" -Dtarget.utf16="true" -Dutf16="1" -I"/usr/local/lib/haxe/lib/hxcpp/4,2,1/" -I"/usr/local/lib/haxe/lib/hxWidgets/1,7,2/src/" -I"/usr/local/lib/haxe/lib/haxeui-hxwidgets/1,2,3/" -I"/usr/local/lib/haxe/lib/hscript/2,4,0/" -I"/usr/local/lib/haxe/lib/haxeui-core/1,2,3/" -I"src/" -I"" -I"/usr/local/lib/haxe/extraLibs/" -I"/usr/local/share/haxe/extraLibs/" -I"/usr/local/bin/extraLibs/" -I"/usr/local/lib/haxe/std/cpp/_std/" -I"/usr/local/share/haxe/std/cpp/_std/" -I"/usr/local/bin/std/cpp/_std/" -I"/usr/local/lib/haxe/std/" -I"/usr/local/share/haxe/std/" -I"/usr/local/bin/std/"

Compiling group: haxe
g++ -Iinclude -I/usr/local/lib/wx/include/osx_cocoa-unicode-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__  -I/usr/local/lib/haxe/lib/hxWidgets/1,7,2//include -DwxUSE_GRAPHICS_CONTEXT -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++ -c -fvisibility=hidden -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -O2 -I/usr/local/lib/haxe/lib/hxcpp/4,2,1/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -Wno-overflow -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=400(haxe) ... tags=[haxe,static]
 - src/haxe/ui/components/_CheckBox/SelectedBehaviour.cpp
 - src/hx/widgets/DataViewListCtrl.cpp
 - src/haxe/ui/core/ComponentTextBehaviour.cpp
 - src/haxe/xml/Parser.cpp
 - src/haxe/ui/util/_Color/Color_Impl_.cpp
 - src/haxe/ui/components/HorizontalRule.cpp
 - src/haxe/ui/containers/_TabView/RemovePage.cpp
 - src/hx/widgets/DataViewToggleRenderer.cpp
Error: ./src/hx/widgets/DataViewListCtrl.cpp:232:28: error: conversion from 'long' to 'const Dynamic' is ambiguous
HXLINE(  69)                    r = v->ptr->GetLong();
                                    ~~~~~~~~^~~~~~~~~
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:21:4: note: candidate constructor
   Dynamic(int inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:22:4: note: candidate constructor
   Dynamic(short inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:23:4: note: candidate constructor
   Dynamic(unsigned int inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:24:4: note: candidate constructor
   Dynamic(unsigned short inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:25:4: note: candidate constructor
   Dynamic(unsigned char inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:26:4: note: candidate constructor
   Dynamic(signed char inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:28:4: note: candidate constructor
   Dynamic(bool inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:29:4: note: candidate constructor
   Dynamic(double inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:30:4: note: candidate constructor
   Dynamic(float inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:31:4: note: candidate constructor
   Dynamic(cpp::Int64 inVal);
   ^
/usr/local/lib/haxe/lib/hxcpp/4,2,1/include/Dynamic.h:32:4: note: candidate constructor
   Dynamic(cpp::UInt64 inVal);
   ^
1 error generated.
/usr/local/lib/haxe/lib/haxeui-hxwidgets/1,2,3/haxe/ui/backend/ComponentImpl.hx:43: characters 17-37 : Warning : Std.is is deprecated. Use Std.isOfType instead.
...
ianharrigan commented 3 years ago

What version of wxWidgets are you using?

perlmonger42 commented 3 years ago

wxmac 3.0.5.1

$ brew install wxwidgets
Warning: wxmac 3.0.5.1_1 is already installed and up-to-date.
To reinstall 3.0.5.1_1, run:
  brew reinstall wxmac

For completeness, I'll add that to the issue description.

ianharrigan commented 3 years ago

So i think this is an hxcpp issue, does this snippet compile for you (it does for me):

            untyped __cpp__("long n = 100");
            var x = untyped __cpp__("n");

It turns into:

HXLINE( 101)            long n = 100;
HXLINE( 102)             ::Dynamic x = n;

I guess an issue needs to be opened on hxcpp if it doesnt for you.

Let me know

Cheers, Ian

PS: btw, i may have mentioned this to you before but you are much better off grabbing wxWidgets from source and building the lib yourself from the latest release version (3.1.4) as ive found that linux / osx distributions are usually woefully out of date.

For osx / linux the process is really painless and totally worth the effort imo: https://github.com/haxeui/hxWidgets#building-wxwidgets-from-source-linux--osx

ianharrigan commented 3 years ago

oh, forgot to mention, i fixed the deprecation warnings also in git version :)

ianharrigan commented 3 years ago

Right, last thing, i may have worked around your issue in hxWidgets git also, but it would be interesting to know if hxcpp does have issues.

So, to summarize:

Cheers, Ian

perlmonger42 commented 3 years ago

Ian: Using your workaround from 213e39f solved the getLong problem. Another compile error showed up in wx/widgets/*.cpp, but I followed your advice to build wxWidgets myself to get a newer version, and that solved the last problem.

I was able to build and run the haxeui-hxwidgets starter app.

Thank you for all your help, @ianharrigan!