Can we call functions before defining it?

c, function

Solution

C89 allow this by implicitly converting the return type of function and parameter passed to it to `int`. See here.

But, this is not valid in C99 and later. This has been omitted from the standard. Either you have to declare a prototype for your function or define it before `main`. See the result here. There is a compile time error in this case.

Problem

``` #include <stdio.h> void main() { m(); } void m() { printf("hi"); } ``` Output `hi` Warnings ``` main.c:11:10: warning: conflicting types for 'm' [enabled by default] void m() ^ main.c:7:9: note: previous implicit declaration of 'm' was here m(); ^ ``` Why this program runs successfully even though `m()` is called before it is defined? And what is the meaning of the warning?

Original source