How to avoid integer promotion in C?
问题 It is not clear how to write portable code in C, using wide-character API. Consider this example: #include <locale.h> #include <wchar.h> #include <wctype.h> int main(void) { setlocale(LC_CTYPE, "C.UTF-8"); wchar_t wc = L'ÿ'; if (iswlower(wc)) return 0; return 1; } Compiling it with gcc-6.3.0 using -Wconversion option gives this warning: test.c: In function 'main': test.c:9:16: warning: conversion to 'wint_t {aka unsigned int}' from 'wchar_t {aka int}' may change the sign of the result [-Wsign