1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Veriable problem

Discussion in 'C' started by techinspiration, May 22, 2010.

  1. techinspiration

    techinspiration New Member

    Joined:
    Feb 14, 2010
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    0
    Hi everybody,

    in a .h header file
    i want to declare a var as

    extern struct mytype a[200];


    after I include the header file in a dot c file


    and define the var in the global scope of the dot c file as

    struct mytype a[200];

    but the compiler
    complains the redefinition occurs,

    how to cope with it? thanks in advance.
     
  2. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    in the h header file, i also tried declare the var as
    extern struct mytype *a;

    it differs nothing.

    I know if in .h file

    i declare
    extern int a;

    in dot c file,
    i define
    int a = 1;

    it would ok, why??

    what's difference between the two variables?
     
  3. creative

    creative New Member

    Joined:
    Feb 15, 2010
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    in a .h header file
    i want to declare a var as

    extern struct mytype a[200];

    after I include the header file in a dot c file
    and define the var in the global scope of the dot c file as

    struct mytype a[200];

    but the compiler complains the redefinition occurs,

    Where have you defined struct mytype?
     

Share This Page