Hi,
I have a query. I have the following code :
In the above code, I have declared function func() as returning integer and made a call to it in function main() expecting a return from it. This function func() is declared separately in the another file :Code:#ifndef TEST_H_INCLUDED #include"test.h" #endif extern int func(); int main(void) { int ret = func(); printf("\n Executed!!! with ret[%d] \n", ret); return ret; }
Here I have defined the functon func() but please note that the signature of this function here says that it returns nothing (void).Code:#ifndef TEST_H_INCLUDED #include"test.h" #endif void func() { printf("\n Inside func()\n"); }
When I compile the above two files with gcc on linux system, I see no compilation or Linking errors and the executable works fine with func() being called.
Just wanted to ask how is this possible as the declaration and definition of func() has different signatures?



1Likes
LinkBack URL
About LinkBacks



