confused about extern use



I have seen a header file in which one structure is defined with
extern declaration in a header file and declared one variable of that
structure in one C-file. The code goes as mentioned below . I am
confused with the way it is declared and defined.

a.h
-------

:
:
:struct abc {
unsigned long a;
unsigned long b;
};
extern struct abc abc;
:
:

file.c
-------

:
#include <a.h>
:
:
struct abc abc;
:
:

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.

Thanks
Das

.



Relevant Pages

  • Re: confused about extern use
    ... extern declaration in a header file and declared one variable of that ... extern struct abc abc; ...
    (comp.lang.c)
  • Re: Declaration does not declare anything error
    ... struct foo_1 { ... Putting the definition of struct abc inside the definition of struct ... because the above declaration is functionally ...
    (comp.lang.c)
  • Re: Declaration does not declare anything error
    ... struct foo_1 { ... }' in a declaration of a 'struct' type is required to declare a _member_ of that struct type. ... In your first case the nested declaration of 'struct abc' does not declare any member of 'foo_1', So, your code is broken. ...
    (comp.lang.c)
  • Re: Declaration does not declare anything error
    ... struct foo_1 { ... Putting the definition of struct abc inside the definition of struct ... because the above declaration is functionally ...
    (comp.lang.c)
  • Re: Basic, basic, C question!
    ... This means you have to split into a declaration and definition, ... struct foo_type ... extern foo_type foo; ...
    (microsoft.public.vc.language)