问题
Possible Duplicate:
Can I make GCC warn on passing too-wide types to functions?
Many times I cause bugs by passing a long to an integer function.
Can I make gcc warn me when I'm doing that?
回答1:
Try -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
来源:https://stackoverflow.com/questions/10262983/make-gcc-warn-implicit-conversions