Make gcc warn implicit conversions [duplicate]

痞子三分冷 提交于 2020-12-29 06:58:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!