可能重复:
Can I make GCC warn on passing too-wide types to functions?
很多时候我通过将long传递给整数函数来导致错误。
当我这样做时,我可以让gcc警告我吗?
答案 0 :(得分:9)
尝试-Wconversion
。
int fn(int);
int bar(long x) { return fn(x); }
gcc -c t.c -Wconversion
t.c: In function ‘bar’:
t.c:3: warning: conversion to ‘int’ from ‘long int’ may alter its value