Coding Villa Forum
FAQs
Advertisements

Explain and resolve Linker error undefined symbol i in C.

Iram Online 4/3/2012 5:13:23 PM

Hello Friends!

I have created a main function in C for printing variable size. I have also declare and initialize a global variable i. But on running that function a linker error arise with the error message undefined symbol_i. I am not understanding the logic behind that error as i have define that variable. Please friends explain the reason of error. Here is the code of function.

main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}

Waiting for you guidance.

Thanks

Share with Friends

Advertisements

Answer

srini Online 8/2/2012 9:08:24 PM

use extern variable globally . ie before main function, then u wont get this error..
extern is used to link to somwhere..

see here to know more about extern :
http://stackoverflow.com/questions/856636/effects-of-the-extern-keyword-on-c-functions
Share with Friends

Post reply

 

Enter This Code
Captcha
 

Subscribe

Email me when people reply


Subscribe to the