简体   繁体   English

C中的函数隐式声明

[英]Implicit declaration of function in C

Is there any version of C, or any compiler that does not allow implicit declaration of functions? 是否有C版本或不允许隐式声明函数的任何编译器?

For example. 例如。 Using mingw compiler, if I use the printf function within my program without including stdio.h, it compiles my program, displaying a warning "incompatible implicit declaration of built-in function 'printf'". 使用mingw编译器,如果我在程序中使用printf函数而不包括stdio.h,它将编译我的程序,并显示警告“内置函数'printf'的隐式声明不兼容”。

i would like to know if there is some version of C, or some compiler, which does not compile my program in these situations. 我想知道是否存在某些版本的C或某些编译器,在这些情况下不会编译我的程序。

Best regards. 最好的祝福。

编译时使用-Werror选项,所有警告均将视为错误。

You can use -Werror compiler option while compiling your code. 您可以在编译代码时使用-Werror编译器选项。 It will consider all warning as error . 它将所有警告视为error I like to compile my source code using these option. 我喜欢使用这些选项来编译我的源代码。

gcc -Wall -Werror -Wshadow -Wextra SOURCE.c -Wfloat-equal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM