Hello, I have the following three files: greet.h ---cut-here---cut-here---cut-here #ifndef __GREET_H__ #define __GREET_H__ // greet is not declared to take any arguments void greet(); #endif // __GREET_H__ ---cut-here---cut-here---cut-here greet.c ---cut-here---cut-here---cut-here #include <stdio.h> void greet() { printf("Hello, Anybody!\n"); } ---cut-here---cut-here---cut-here hello.c ---cut-here---cut-here---cut-here #include "greet.h" int main() { // call greet with an argument greet("World!\n"); return 0; } ---cut-here---cut-here---cut-here Using gcc-4.1.1 on Debian testing/unstable: $ gcc greet.c hello.c # no error or warning $ gcc -Wall greet.c hello.c # no error or warning $ gcc -Wall -pedantic greet.c hello.c In file included from hello.c:1: greet.h:6:8: warning: C++ style comments are not allowed in ISO C90 greet.h:6:8: warning: (this will be reported only once per input file) $ gcc -Wall -pedantic -ansi greet.c hello.c In file included from hello.c:1: greet.h:6:8: warning: extra tokens at end of #endif directive If I change the greet declaration to "void greet(void)" I get a compilation error error. But it is puzzling I do not get one by default. 1. Shouldn't gcc at least warn about greet being called with and argument that is not present in the declaration? 2. What -W option should I use to get the warning (if it is not by default in Wall)? florin -- If we wish to count lines of code, we should not regard them as lines produced but as lines spent. -- Edsger Dijkstra
Attachment:
signature.asc
Description: Digital signature