cancel
Showing results for 
Search instead for 
Did you mean: 

Why did I get this error "conflicting types for 'GPIO_RegDef_t'"?

DK.7
Senior

I'm beginner and trying to write a driver for GPIO and received this error when compiling code.

What do I do wrong when creating a structure?

A library #include <stdint.h> at the beginning of the code included!

typedef struct        // RM -> Table 39. GPIO register map and reset values
{
	volatile uint32_t MODER;   // Address offset: 0x00
	volatile uint32_t OTYPER;  // Address offset: 0x04
	volatile uint32_t OSPEEDR; // Address offset: 0x08
	volatile uint32_t PUPDR;   // Address offset: 0x0c
	volatile uint32_t IDR;     // Address offset: 0x10
	volatile uint32_t ODR;     // Address offset: 0x14
	volatile uint32_t BSRR;    // Address offset: 0x18
	volatile uint32_t LCKR;    // Address offset: 0x1c
	volatile uint32_t AFR[2];  // Address offset: 0x20-0x24 GPIO alternate function LOW register AF[1]:  GPIO alternate function HIGH register AF[2]:
} GPIO_RegDef_t; 

7 REPLIES 7
DK.7
Senior

Sorry forgot a screen attach!0693W00000Dplq3QAB.png

AM P.1
Associate

did u solve it??, i am stuck at same issue

You get this error because the compiler sees at least two conflicting declarations of the type.

The compiler tells you where exactly it finds the other definition. Just read carefully what it tells you.

sir, its not showing anything

Hmm.. have you tried to compile it, or just the editor shows the mark? (why "No consoles to display"?)

xuanduongdev1
Associate

Hey, check again your header file. I think you included another header file in this where shouldn't be included any header file. Remove that and build again. 

an_tin
Associate

Greetings, I have solved this problem by deleting 1 "#include stm32f407xx.h" in the driver.c file. Therefore, the general header file (stm32f407xx.h) is only included once in the driver.h file. Hope it helps!