Hi,
I am doing the below steps
1. I am created new folder and created below files and executed.
1. created extern.c file
//extern.c
Code:
#include<stdio.h>
void fun()
{
printf("hai\n");
}
2.created main.c file
//main.c
Code:
#include<stdio.h>
int main()
{
fun();
return 0;
}
3.compile the above program with #cc main.c extern.c
4.The program compiling with out errors and creates binary file
4.after running the binary file , we will get the output hai
5.Please see the below execution stpes
Code:
$ vi extern.c
$ cat extern.c
#include<stdio.h>
void fun()
{
printf("hai\n");
}
$ vi main.c
$ cat main.c
#include<stdio.h>
int main()
{
fun();
return 0;
}
$ cc main.c extern.c -Wall
main.c: In function ‘main’:
main.c:4: warning: implicit declaration of function ‘fun’
$ ls
a.out extern.c main.c
$ ./a.out
hai
$
At least it showing output as wt i expected by warning messages at compilation time.
my question is
why it it compiling for functions with waring messages. why it is not compiling(showing error messages) for variables with out using "extern int i"? is it limitaion?. For variables i should include that "extern.c" file?
thanks in advance.