0

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.

6
  • Why not look at the various options available to the various compilers? Most allow you to make the warnings as errors Commented Apr 18, 2016 at 17:10
  • 1
    Use -Werror and the code won't compile. Commented Apr 18, 2016 at 17:14
  • The 1999 standard did away with implicit int, so compiling with -std=c99 -Werror should catch any implicit declarations. Commented Apr 18, 2016 at 17:36
  • 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? Commented Apr 18, 2016 at 17:37
  • 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. Commented Apr 18, 2016 at 18:12

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.