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

Error: conflicting types for....

Discussion in 'C' started by gplkrsna, Feb 25, 2010.

  1. gplkrsna

    gplkrsna New Member

    Joined:
    Apr 11, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I'm looking solution for the following problem.

    Problem:
    I have two libraries with two different queue implementations. but with same structure name as "queuetype".

    Now if I include both of the header files in my code, compilation will go for toss saying "error: conflicting types for 'queuetype' "

    I need to include both the files.

    How can I resolve this issue??

    Thanks in advance.
     
  2. thillai_selvan

    thillai_selvan New Member

    Joined:
    Feb 20, 2010
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Actually in the both header files you are having the same structure. So when you are trying to include the second header file it will be like another definition or re-declaration for that structure. Thats why this kind of situation is occuring
     
  3. gplkrsna

    gplkrsna New Member

    Joined:
    Apr 11, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Yeah, is there a solution for this?
     
  4. thillai_selvan

    thillai_selvan New Member

    Joined:
    Feb 20, 2010
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    You can use the macros for this.
    IFDEF structure_name
    check this condition

    If the structure is already defined then UNDEF of that structure.
    Hopes this will help
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Very often you'll see in header files something like
    Code:
    // header file foo.h
    #ifndef FOO_H
    #define FOO_H
    
    // header file contents
    
    #endif // FOO_H
    
    If a.h and b.h both include foo.h, and your program has to include a.h and b.h, then this guard will prevent duplicate definition errors caused by the double inclusion of foo.h.
     

Share This Page