开发者

enforing check about returning a value in gcc

I am 开发者_如何学Ccompiling some C/C++ files using gcc.

I noticed today a bug that caused my app to crash. It was caused by the fact that my function didn't return any value (see below). Do you know if there is some flag in gcc enforcing these kind of checking or why the compiler is not warning me about this?

I am compiling C files into object files with a basic -g -D_GNU_SOURCE -o outObjectFile -c myFile.c option.

   //.c file
   int
   myFunc(){
      ...do something
      ..without return statement
   }

   //.h file
   extern int myFun();


When using GCC, always compile with:

-std=c99 -pedantic -Wall -Wextra -Wwrite-strings for C

-ansi -pedantic -Wall -Wextra -Weffc++ for C++

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜