I came across the following problem while reading …just cant get the logic behind this.
auto int c;
static int c;
register int c;
extern int c;
It is given that the first three are definition and last one is declaration ..how come ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The last one with
externdoes not define storage forc. It merely indicates thatcexists somewhere and the linker should be able to resolve it to some globalcdefined elsewhere.If you compiled and linked a single .c file and tried to use the last
cyou’d have a linker error. With the the first 3cs you would not as they have substance (they’ve been defined) in the current compilation unit.If you’d like to learn more about
externand declaration vs definition here’s a good article on the topic. To quote from that article: