// In VS200X: use /J to Changes the default char type from signed char to unsigned char
// In g++ : use -funsigned-char to ...
#include <iostream>
#include <limits>
using namespace std;
int main()
{
#ifndef _CHAR_UNSIGNED
cout << "not defined _CHAR_UNSIGNED" << endl;
#else
cout << "defined _CHAR_UNSIGNED" << endl; // output this word
#endif
cout << CHAR_MAX << endl; // output 255
cout << CHAR_MIN << endl; // output 0
cout << "char_max = " << (int)numeric_limits<char>::max() << endl; // output 127 ( error )
cout << "char_min = " << (int)numeric_limits<char>::min() << endl; // output 128 ( error )
return 0;
}
/*
查看了一下其库代码,完全正确。
错误发生在 #include <limits> 上,虽然char变了,_CHAR_UNSIGNED变了,但它根本没重新参与编译
*/