emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 660 forks source link

undeclared identifier 'strtoll_l' and use of undeclared identifier 'strtoull_l' in c++\v1\locale #1374

Open yosmo78 opened 2 months ago

yosmo78 commented 2 months ago

Hi, So I installed the Emsdk (3.1.49) a couple months ago using the following method on x64, Windows 10 Pro on a 12th Gen i5-12400

1: download https://github.com/emscripten-core/emsdk (code->Download ZIP) 2: extract name folder to emsdk and move to C: 3: opem cmd as administrator 4: run: cd C:\emsdk 5: run: emsdk install latest 6: run: emsdk activate latest --system 7: run: emsdk_env.bat --permanent 8: restart computer 9: run: em++ -v (to verify install)

Everything was compiling fine until I included functional #include <functional>

Which let to the following errors:

  In file included from C:\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\functional:526:
  In file included from C:\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\__functional/boyer_moore_searcher.h:27:
  In file included from C:\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\vector:325:
  In file included from C:\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\__format/formatter_bool.h:20:
  In file included from C:\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\__format/formatter_integral.h:35:
C:\emsdk\upstream\emscripten\cache\sysroot\include\c++\v1\locale(719,68): error G30564CF7: use of undeclared identifier 'strtoll_l'
    719 |     long long
__ll                                               = strtoll_l(__a,
&__p2, __base, _LIBCPP_GET_C_LOCALE);
| ^
C:\emsdk\upstream\emscripten\cache\sysroot\include\c++\v1\locale(751,68): error G30564CF7: use of undeclared identifier 'strtoull_l'
    751 |     unsigned long long
__ll                                      = strtoull_l(__a, &__p2,
__base, _LIBCPP_GET_C_LOCALE);
| ^
  2 errors generated.

So I tried updating to 3.1.58

using emsdk update and then emcc --clear-cache

which didn't resolve the issue so I then cleared out the emsdk folder and did the following 1: download https://github.com/emscripten-core/emsdk (code->Download ZIP) 2: extract name folder to emsdk and move to C: 3: opem cmd as administrator 4: run: cd C:\emsdk 5: run: emsdk update 6: run: emsdk install latest 7: run: emsdk activate latest --system 8: run: emsdk_env.bat --permanent 9: restart computer 10: run: em++ -v (to verify install) 11: run: emcc --clear-cache

But still won't compile.

I found this error also occurs with using ostream or any file that has ostream in it too since it includes locale

Any help is appreciated on how to overcome this, thanks

sbc100 commented 2 months ago

Can you share an full example of a source file that generates this error?

I see that we do support strtoull_l in emscripten via the include/compat/xlocale.h header, but I'm not clear how that header is not bring included in your case.

yosmo78 commented 2 months ago

Ok so I made a minimal program to test it

#include <functional>

int main()
{
    return 0;
}

and it worked fine. So it must have to do with my project structure which would be hard to track down as an example.

it looks like # include <__support/musl/xlocale.h> is getting included in some files but not other files.

but I found if i forcefully include #include <locale> before any of the includes in the problematic files it compiles fine.

So in summary there is a bug but I don't know how to repo it, so you can mark this as closed.