Skip to main content
Graduate II
August 19, 2021
Question

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

  • August 19, 2021
  • 4 replies
  • 8138 views

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; 

    This topic has been closed for replies.

    4 replies

    DK.7Author
    Graduate II
    August 19, 2021

    Sorry forgot a screen attach!0693W00000Dplq3QAB.png

    Visitor II
    August 30, 2022

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

    Super User
    August 30, 2022

    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.

    Visitor II
    September 1, 2022

    sir, its not showing anything

    Visitor II
    March 26, 2024

    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. 

    Visitor II
    May 18, 2024

    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!