HaxeFoundation / hxcpp

Runtime files for c++ backend for haxe
Other
298 stars 189 forks source link

use of undeclared identifier '_wsetlocale'; with HX_SMART_STRINGS #867

Open Dexus opened 4 years ago

Dexus commented 4 years ago

I try to compile a wasm via lime test emscripten -webassembly but I get this error following. How can i fix it and compile it?

Compiling group: hxcpp_std
emcc -c -fvisibility=hidden -O1 -fpic -fPIC -DEMSCRIPTEN -Wno-overflow -Wno-parentheses -Wno-unknown-warning-option -Wno-null-dereference -Wno-unused-value -Wno-format-extra-args -Wno-bool-conversion -Wno-warn-absolute-paths -DSTATIC_LINK(static) -DHXCPP_VISIT_ALLOCS(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=400(haxe) -I/home/josef/haxelib/hxcpp/4,0,64/include ... tags=[haxe,static]
 - Sys.cpp 
Error: /home/josef/haxelib/hxcpp/4,0,64/src/hx/libs/std/Sys.cpp:174:14: error: use of undeclared identifier '_wsetlocale'; did you mean 'setlocale'?
      return _wsetlocale(LC_TIME,l.wchar_str());
             ^~~~~~~~~~~
             setlocale
/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/libc/locale.h:53:7: note: 'setlocale' declared here
char *setlocale (int, const char *);
      ^
/home/josef/haxelib/hxcpp/4,0,64/src/hx/libs/std/Sys.cpp:174:34: error: cannot initialize a parameter of type 'const char *' with an rvalue of type 'const wchar_t *'
      return _wsetlocale(LC_TIME,l.wchar_str());
                                 ^~~~~~~~~~~~~
/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/libc/locale.h:53:35: note: passing argument to parameter here
char *setlocale (int, const char *);
                                  ^
2 errors generated.
shared:ERROR: '/home/josef/Dokumente/git/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/local/include -c -fvisibility=hidden -O1 -fpic -fPIC -DEMSCRIPTEN -Wno-overflow -Wno-parentheses -Wno-unknown-warning-option -Wno-null-dereference -Wno-unused-value -Wno-format-extra-args -Wno-bool-conversion -DSTATIC_LINK -DHXCPP_VISIT_ALLOCS -DHX_SMART_STRINGS -DHXCPP_API_LEVEL=400 -I/home/josef/haxelib/hxcpp/4,0,64/include -x c++ -frtti --std=c++11 -Wno-invalid-offsetof -Wno-return-type-c-linkage -DEMSCRIPTEN /home/josef/haxelib/hxcpp/4,0,64/src/hx/libs/std/Sys.cpp -Xclang -isystem/home/josef/Dokumente/git/emsdk/upstream/emscripten/system/include/SDL -c -o /home/josef/Dokumente/git/FlixelTut/export/emscripten/obj/obj/emscripten-stat/63226c86_Sys.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)

EDIT:

I'm unsing Ubuntu 18.04 - all software up to date.

royalstream commented 3 years ago

Feb 2021. I'm having the same issue, using macOS Catalina 10.15.7 - all software up to date (except for Haxe where I'm using 4.1.5 instead of 4.2 because HaxeFlixel doesn't work with 4.2)

ghost commented 3 years ago

Ditto on Debian 10, Haxe 4.1.5, hxcpp 4.2.1

JonnycatMeow commented 1 year ago

has anybody fixed this issue?

lujunq commented 8 months ago

Same problem here on Windows 11 - hxcpp 4,3,2 - on March 2024.

mikaib commented 6 months ago

I just had this problem aswell, I asked what the problem could be in the Haxe discord. https://discord.com/channels/162395145352904705/162395145352904705/1238082566175592449

apparently, using emscripten magically sets the NEKO_WINDOWS define, which (probably?) shouldn't happen. Or it's that this piece of code should specifically not run on emscripten buillds. This causes the build faliure at: https://github.com/HaxeFoundation/hxcpp/blob/b1359b43354aa52e7da29dbdd711bace63a51685/src/hx/libs/std/Sys.cpp#L177

As the check is #if defined(NEKO_WINDOWS) && defined(HX_SMART_STRINGS) I tried disabling smart strings using -D disable-unicode-strings as a test and sure enough that worked.

If I can find the problem I'll see if I can make a PR, or perhaps someone else can make one? Anyhow, that's all.

Thanks to Zeta and dazKind for their help finding this problem.

With kind regards, MKI