adtools icon indicating copy to clipboard operation
adtools copied to clipboard

Get a host of wchar related errors when including <string> with clib2

Open ksdhans opened this issue 6 years ago • 5 comments

I get a host of "not declared" errors related to wchar handling when using the -mcrt=clib2 option with G++ v8.1.0.

You can test this easily:

  1. Create a source file with #include
  2. Compile it with g++ -mcrt=clib2

You'll get errors for functions such as: ::mbrtowc ::wcscoll ...

ksdhans avatar Jan 18 '19 03:01 ksdhans

I've managed to manually disable wchar by setting _GLIBCXX_USE_WHCAR_T to 0 in the clib2/bits/c++config.h file.

Please update the repository version until clib2 supports wchar.

ksdhans avatar Jan 18 '19 03:01 ksdhans

Am 2019-01-18 04:25, schrieb ksdhans:

I get a host of "not declared" errors related to wchar handling when using the -mcrt=clib2 option with G++ v8.1.0.

You can test this easily:

  • Create a source file with #include
  • Compile it with g++ -mcrt=clib2

You'll get errors for functions such as: ::mbrtowc ::wcscoll

Please check with the latest version (gcc 8.2 is current), as I added some of these functions to clib2. This was necessary for Polybios PDF viewer and the current set of functions is enough for it at least. At https://dl.bintray.com/sba1/adtools-native/, you see the special archive files as e.g. adtools-os4-clib2-20181211-695.lha that should be installed together with adtools-os4-8-20181211-695.lha if you are using native compiler suite.

The cross compiler setup automatically takes care of it.

Let me know if this works or if there are any functions still missing.

sba1 avatar Jan 18 '19 07:01 sba1

I was able to compile stuff that needs wchar (like the JSON from nlohmann) by using a simple workaround:


namespace std {
static inline long double strtold(const char * a, char ** b) { return strtod(a,b);} 

        //Also another workaround for missing wstring that is required by new versions of the JSON parser.
        class wstring : public string {};
        
}

Maybe this helps.

AV00 avatar Jan 18 '19 11:01 AV00

Just tried the latest clib2. Currently getting the following: struct stat64 has incomplete type struct dirent has no member named d_type (and the associated DT_* macros are missing too)

Also, waitselect()'s last parameter (sigmask) is unsigned int* in newlib, and unsigned long* in clib2, and the compiler doesn't like that difference.

I didn't get the wchar errors, but stat64 being missing prevented multiple files from compiling, so I can't guarantee that they're all gone.

ksdhans avatar Feb 06 '19 08:02 ksdhans

Am 2019-02-06 09:31, schrieb ksdhans:

Just tried the latest clib2. Currently getting the following: struct stat64 has incomplete type struct dirent has no member named d_type (and the associated DT_* macros are missing too)

Yes, clib2 doesn't support these yet. There are Issues in the clib2 repo that suggest the addition of these features. They are definitively needed and can be added by anyone for the clib2 case.

Also, waitselect()'s last parameter (sigmask) is unsigned int* in newlib, and unsigned long* in clib2, and the compiler doesn't like that difference.

Yes, that's a problem but more for the clib libraries. They should agree on the type. If you are compiling to C you could cast to (void*) though, even though this is inelegant.

sba1 avatar Feb 06 '19 09:02 sba1