在 6/12/21 4:01 AM, Martin Storsjö 写道:

If I understand things correctly, the backstory is that with MSVC, you can pass an option (/J) to the compiler to request 'char' to be an unsigned data type. If you pass this option, then the compiler defines _CHAR_UNSIGNED. If you have _CHAR_UNSIGNED define and include locale.h (in MSVC 2013 and earlier), this does some sort of header trick which causes an undefined reference to the _charmax symbol, which then would pull in something equivalent to our charmax.c. In UCRT, this trick has been renamed and uses the symbol __do_unsigned_char_lconv_initialization instead of _charmax.

These tricks aren't hooked up in mingw-w64 headers, and our chars default to signed, so this is indeed the right default, but if we want to follow suit we'd need to do something similar. But I'm not sure if changing to unsigned chars is a setting we should spend extra effort on actually supporting anyway...


GCC defines `__CHAR_UNSIGNED__` if `-funsigned-char` is set.

Therefore, it should be trivial to implement:

    #ifdef __CHAR_UNSIGNED__
    extern int mingw_initcharmax;
    __declspec(selectany) int* __mingw_use_char_max = &mingw_initcharmax;
    #endif

If we can add it for free, why not?

(BTW can we rename those global symbols so they have leading double 
underscores?)




--
Best regards,
Liu Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to