Re: confused about extern use
- From: Chris Dollin <chris.dollin@xxxxxx>
- Date: Wed, 21 Feb 2007 09:05:57 +0000
Lalatendu Das wrote:
On Feb 21, 12:22 pm, Ian Collins <ian-n...@xxxxxxxxxxx> wrote:
Lalatendu Das wrote:Actually what u mean by another compilation unit.
Here in the above example I am confused about, what extra the coder
going to achieve by declaring it as extern in the header file a.h.
So it can be used in another compilation unit.
There is no `u`.
A compilation unit is the thing you feed to the C compiler: a
source file and its #includes.
If my assumption is
not wrong do u mean If I will try to compile another C-program no need
to include this header file or what ?
A compilation unit [which need not be a program] which references
the stuff in file.c typically does so by #including "a.h". That
makes available the struct definition and the extern.
[Actually, it's more likely that you'll have a header foo.h
corresponding to the file foo.c; ie the name is the same but
the suffix is different. That makes it easier to keep track of
what's related to what. Sometimes more complex schemes are
needed, but this is a good place to start.]
I don't think so it will work in that case. And in any case if I have
to include this header file to define one variable of structure type
"abc" then why to declare it extern there.
Because it's /defined/ somewhere else.
--
Chris "electric hedgehog" Dollin
Meaning precedes definition.
.
- Follow-Ups:
- Re: confused about extern use
- From: pete
- Re: confused about extern use
- References:
- confused about extern use
- From: Lalatendu Das
- Re: confused about extern use
- From: Ian Collins
- Re: confused about extern use
- From: Lalatendu Das
- confused about extern use
- Prev by Date: Re: Pointers in C
- Next by Date: Re: Pointers in C
- Previous by thread: Re: confused about extern use
- Next by thread: Re: confused about extern use
- Index(es):
Relevant Pages
|