How do I resolve an "error: conflicting types" problem when there is no conflict?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaSl_2925376
Level 2
Level 2
First like given

Project was going really well until I got the following error messages moaning about a conflicting type:-

In file included from C_SourceCode\CommandDecoder.c:27:0:

./GPS.h:27:2: error: conflicting types for 'GPS_LOC_t'

}GPS_LOC_t;

  ^

In file included from C_SourceCode\CommandDecoder.c:25:0:

./GPS.h:27:2: note: previous declaration of 'GPS_LOC_t' was here

}GPS_LOC_t;

  ^

Where is the conflicting type? If I remove it it says it's not there!

If I rename it, still says it's conflicting. With what?

Has anyone had this problem and managed to overcome it? Error could be somewhere else and just falsely reporting it as the error.Help please.

I had the same problem ( different project ) 3 months ago. Only way I could find to get out of it was to create a new project and copy items across to it.

Conflict went away somehow! Luckily I had only just started the project so wasn't too difficult.

I'm within 2 weeks of finishing this one and I don't really want to start all over again. Must be a simple solution somewhere - isn't there?

Dafydd

0 Likes
1 Solution
DaSl_2925376
Level 2
Level 2
First like given

Panic over. After a good nights sleep and a clear head I saw the error. My error! I had included a header file twice. Despite looking for that sort of thing I couldn't see it until morning.

View solution in original post

0 Likes
3 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

This looks like same struct or class is being defined 2nd time in CommandDecoder.c line 27 and line 25.

Usually this happens when you don't protect a header from multiple include(s).

So in my case, usually I write a header something like

GPS.h

=========================

#ifndef _GPS_H_

#define _GPS_H_

typedef struct {

/* I don't know what will be placed there, though */

} GPS_LOC_t ;

#endif /* _GPS_H_ */

=========================

moto

DaSl_2925376
Level 2
Level 2
First like given

Panic over. After a good nights sleep and a clear head I saw the error. My error! I had included a header file twice. Despite looking for that sort of thing I couldn't see it until morning.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Congrat!

I'm glad hearing that you are OK, now.

Have a good day!

moto