-1

When I'm compiling a simple program like 'hello world', I'm getting a warning at printf function. Here is the error message:

hey.c:4:5: warning: implicit declaration of function 'puts' is invalid in C99
  [-Wimplicit-function-declaration]
puts("Hello World!");
^
1 warning generated.
ld: can't write output file: a.out for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • googling the warning will give you all you want – Arjun Sreedharan Mar 21 '15 at 03:46
  • @ArjunSreedharan thats exactly what I did when I saw the question – SemperAmbroscus Mar 21 '15 at 03:48
  • Did you write `printf()` in your source code, or did you write `puts()` and make a typo in writing the question (where you mention `printf()`). Since the message shows `puts()`, I rather think you wrote `puts()`, but `clang` is clever enough to replace a call like `printf("Hello World!\n");` with `puts("Hello World!");` (and so is GCC), so it could be either. – Jonathan Leffler Mar 21 '15 at 06:06

1 Answers1

0

Yes you need to include stdio.h in your code . Normally the compilers allow you to use printf without the header file but they generate a warning

Achyuta Aich
  • 569
  • 1
  • 5
  • 13