Joachim Schmitz wrote:
> johnnash wrote:
>> So you mean to say extern is only to be used in .h files for
>> declaration purpose so that we can define the variable in the .c
>> files(which includes the .h file).
> Yes.
No.
extern int a = 0;
would have been okay too (though more typing than is necessary).
A variable declaration (with a complete type) without the "extern"
specifier is a definition.
A variable declaration _with_ the "extern" specifier, and
initialization, is a definition.
A variable declaration with the "extern" specifier, and no
initialization, is not a definition (refers to an object that
should be defined elsewhere).
--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/