Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Error: conflicting types for.... (http://www.go4expert.com/forums/error-conflicting-types-t21105/)

gplkrsna 25Feb2010 15:45

Error: conflicting types for....

I'm looking solution for the following 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.

thillai_selvan 25Feb2010 15:49

Re: Error: conflicting types for....
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

gplkrsna 25Feb2010 15:51

Re: Error: conflicting types for....
Yeah, is there a solution for this?

thillai_selvan 25Feb2010 15:54

Re: Error: conflicting types for....
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

xpi0t0s 26Feb2010 13:30

Re: Error: conflicting types for....
Very often you'll see in header files something like

// 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.

All times are GMT +5.5. The time now is 12:48.