Re: keyword extern
umbs.sairam_at_gmail.com
Date: 06/26/04
- Next message: Joona I Palaste: "Re: Lvalue Required(wierd)..."
- Previous message: Kenneth Brody: "Re: Usual way to hide jpegs. Extraction off application jpgs??"
- In reply to: Emmanuel Delahaye: "Re: keyword extern"
- Next in thread: CBFalconer: "Re: keyword extern"
- Reply: CBFalconer: "Re: keyword extern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Jun 2004 09:10:08 -0700
> > 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.
>
> Sorry, I failed to understand your point. 'extern' doesn't make global a
> variable. It's the lack of 'static' that makes it.
I am sorry if I did not explain myself clearly. If we have the
following files
(pseudo-code)
head.h
/* common to all files */
head1.h
/* used in file1.c */
file1.c
include "head.h"
include "head1.h"
/* code of file1.c */
.....
headN.h
/* used in fileN.c */
fileN.c
include "head.h"
include "headN.h"
/* code of fileN.c */
Now, declare a variable in head1.h as int i and define it in file1.c
as i = 10. My argument in the above post is, if "i" is declared
multiple times using extern in all the files file2.c ... fileN.c then
the significance of "extern"ing is lost. The programmer could have
acheived the same functionality by declaring the variable in head.h
sarma
- Next message: Joona I Palaste: "Re: Lvalue Required(wierd)..."
- Previous message: Kenneth Brody: "Re: Usual way to hide jpegs. Extraction off application jpgs??"
- In reply to: Emmanuel Delahaye: "Re: keyword extern"
- Next in thread: CBFalconer: "Re: keyword extern"
- Reply: CBFalconer: "Re: keyword extern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|