让gcc警告隐式转换

时间:2012-04-21 21:01:35

标签: c gcc warnings

  

可能重复:
  Can I make GCC warn on passing too-wide types to functions?

很多时候我通过将long传递给整数函数来导致错误。

当我这样做时,我可以让gcc警告我吗?

1 个答案:

答案 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