0
votes

Is there any version of C, or any compiler that does not allow implicit declaration of functions?

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'".

i would like to know if there is some version of C, or some compiler, which does not compile my program in these situations.

Best regards.

2
Why not look at the various options available to the various compilers? Most allow you to make the warnings as errors - Ed Heal
Use -Werror and the code won't compile. - 2501
The 1999 standard did away with implicit int, so compiling with -std=c99 -Werror should catch any implicit declarations. - John Bode
This is interesting. However, I am still interested in the original question. Is there any compiler that, in its standard operation, does not compile a program with implicit declaration? - Zaratruta
The compiler has already issued a diagnostic for you. Ignoring this diagnostic means the program will have undefined behavior. Warnings should be treated as errors unless you never plan to change compilers or upgrade your compiler. - jxh

2 Answers

1
votes

When compiling use -Werror option and all warnings will be considered errors.

0
votes

You can use -Werror compiler option while compiling your code. It will consider all warning as error. I like to compile my source code using these option.

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