how to get compile warning
I'm quite surprised when I compile the following code without any warning using g++ 4.1.2 with -Wall -Wextra -Wconversion enabled.
I want g++ to show me every warning to avoid potential harm. I have to stick to g++ 4.1.2.
#include <stdint.h>
#include <string>
using namespace std;
int main()
{
uint8_t u1=1;
uint64_t u64=1000;
string s1="";
u1=u64; // want warning here
s1=u64; // want warning here
s1=u1;
}
I'm afraid GCC before 4.3 doesn't seem to support this. The description of -Wconversion
changed between 4.2 and 4.3 to reflect the new warning behavior, and there is no indication that pre-4.3 GCC would check for this.
上一篇: 用于大型字符串的SHA1 JavaScript实现
下一篇: 如何获得编译警告