8

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?

Community
  • 1
  • 1
mikebloch
  • 1,577
  • 11
  • 21
  • 3
    You should really try searching for your answers before just posting them here. This is one quick google search away for your exact terms. http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html – Thomas Apr 21 '12 at 21:03

1 Answers1

18

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
Employed Russian
  • 199,314
  • 34
  • 295
  • 362