I always use char
as unsigned char
and wchar_t
as wint_t
. Given that, does there exist a solution to change function interfaces to use those types with or without recompiling glibc? See also this question: How to change wchar.h to make wchar_t the same type as wint_t?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can pass a command line option to the compiler to make char
unsigned by default. Changing the interface to standard library functions by redefining char
with macros and typedefs is not the correct way to achieve your goal.
For gcc and clang, use -funsigned-char
.
For Visual-C++, use -J
or /J
.
The wide character type wchar_t
is system specific, it typically 32-bit wide on linux systems and wherever the glibc is used, but only 16-bit wide for the Microsoft tools for historical reasons. Changing this type will cause compatibility problems between the compiler and the libraries, don't even think about it.