Re: keyword extern
umbs.sairam_at_gmail.com
Date: 06/26/04
- Next message: Emmanuel Delahaye: "Re: keyword extern"
- Previous message: Minti: "Re: preprozessor and #define Problem"
- In reply to: tweak: "keyword extern"
- Next in thread: Emmanuel Delahaye: "Re: keyword extern"
- Reply: Emmanuel Delahaye: "Re: keyword extern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Jun 2004 01:10:42 -0700
> What's the best way to use extern when using multiplefiles that is
> easiest to maintain?
> Is it best to declare:
>
> extern int a;
>
> in a header file and include the header file in all files except
> where it's defined.
> Or is it better to write
>
> extern int a;
>
> in all the files except where it's originally defined?
One of the purposes of using extern in multiple files is restricting
the visibility of the variable only to the file that needs to "see"
it. In your question, in both the cases the variable "a" is visible in
all the files. In such a situation, there is no benefit in using the
keyword "extern. You might as well declare the variable as global.
sarma
- Next message: Emmanuel Delahaye: "Re: keyword extern"
- Previous message: Minti: "Re: preprozessor and #define Problem"
- In reply to: tweak: "keyword extern"
- Next in thread: Emmanuel Delahaye: "Re: keyword extern"
- Reply: Emmanuel Delahaye: "Re: keyword extern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|