Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 我可以让 GCC 在将过宽的类型传递给函数时发出警告吗?
很多时候,我通过将 long 传递给整数函数来导致错误。
当我这样做时,我可以让 gcc 警告我吗?
试试-Wconversion。
-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