c99
console.txt
C: \ c & gt; gcc hello2.c -o hello2.exe
hello2.c: In function 'lol':
hello2.c: 7: 2: warning: implicit declaration of function 'hello' [-Wimplicit-function-declaration]
hello ();
^
hello2.c: At top level:
hello2.c: 20: 6: warning: conflicting types for 'hello'
void hello (void)
^
hello2.c: 7: 2: note: previous implicit declaration of 'hello' was here
hello ();
^
`
Answer 1, authority 100%
You hello ()
in lol ()
used before declaration.
Either arrange them in the order gutenTag-hello-lol
, or before lol
declare
void hello ();
Answer 2, authority 100%
Before the c99 standard, it was allowed to use (call) functions without explicitly declaring them. In this case, the presence of a call to a similar function f ()
in the code was perceived by the compiler in the same way as if earlier the point of use would have been a declaration of the form:
int f ();
Ie a function is supposed that returns int
and accepts a still unknown, but fixed number of arguments. And, for example, code like this:
int main (void) {
f (1, 2);
return 0;
}
int f (int a, int b) {return 0; }
is perfectly valid for c89. But in c99 this shop was closed, and compilers following strict standards should forbid such code. However, for compatibility, they are often limited to warnings (in your case, just a warning, not an error). To avoid such problems, you need to add a preliminary declaration of the function before calling it (or just move the entire implementation above).