Why is this legal?
extern int foo = 0xF00; // Gets a warning, still compiles
extern void bar() { // No warning
int x;
}
Is there a reason to why this is allowed?
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.
Sometimes it’s useful
Without the
extern, in C++foowould bestaticand have internal linkage (which means you could not usefoofrom another translation unit).The
externin both cases in your example is redundant. In C99 anexterncan make a difference forinlinefunctions..