c - getting Error[Pe020]: identifier "" is undefined in IAR with an typedef enum -
i haven't found solution on internet , why asking here.
my led_typedef variable undefined in mydriverconfig.h. first, have definded in myapplications.h:
/* define prevent recursive inclusion -------------------------------------*/ #ifndef __myapplications_h #define __myapplications_h #ifdef __cplusplus extern "c" { #endif #include "main.h" typedef enum { led1 = 0, led_green = led1 } led_typedef; #define ledn 1 #define led1_pin gpio_pin_0 #define led1_gpio_port gpiob #define led1_gpio_clk_enable() __gpioa_clk_enable() #define led1_gpio_clk_disable() __gpioa_clk_disable() #define ledx_gpio_clk_enable(__index__) (((__index__) == 0) ? led1_gpio_clk_enable() : 0) #define ledx_gpio_clk_disable(__index__) (((__index__) == 0) ? led1_gpio_clk_disable() : 0) void led_on(led_typedef led); void led_off(led_typedef led); void led_toggle(led_typedef led); void mcu_configuration(void); #endif /* __myapplications_h */ then, in myconfigdriver.h:
/* define prevent recursive inclusion -------------------------------------*/ #ifndef __myconfig_h #define __myconfig_h #ifdef __cplusplus extern "c" { #endif #include "main.h" void systemclock_config(void); void mx_led_init(led_typedef led); void mx_can_init(void); void mx_i2c1_init(void); void mx_spi1_init(void); void mx_usart2_uart_init(void); #endif /* __myconfig_h */ i thought definded because main.h included all:
/* define prevent recursive inclusion -------------------------------------*/ #ifndef __main_h #define __main_h #include "stm32f0xx_hal.h" #include "mydriverconfig.h" #include "myapplications.h" #endif /* __main_h */ these errors get:
myapplications.c error[pe020]: identifier "led_typedef" undefined c:\inc\mydriverconfig.h 24 error while running c/c++ compiler main.c error[pe020]: identifier "led_typedef" undefined c:\inc\mydriverconfig.h 24 error while running c/c++ compiler total number of errors: 2 total number of warnings: 0
when include myapplication.h in mydriverconfig.h this:
updating build tree... myapplications.c error[pe020]: identifier "led_typedef" undefined c:\users\inc\mydriverconfig.h 25 error while running c/c++ compiler main.c mydriverconfig.c total number of errors: 1 total number of warnings: 0 i don't understand why have 2 errors when not including myapplications while use led_typdef once in mydriverconfig.h.
i have tried add extern led_typedef led; in myapplication.h without results.
ok, thank you. people interested way working well:
/* define prevent recursive inclusion -------------------------------------*/ #ifndef __main_h #define __main_h #include "stm32f0xx_hal.h" #include "mydriverconfig.h" #include "myapplications.h" #endif /* __main_h */ now in mydriverconfig.h
/* define prevent recursive inclusion -------------------------------------*/ #ifndef __myconfig_h #define __myconfig_h #ifdef __cplusplus extern "c" { #endif #include "stm32f0xx_hal.h" #include "myapplications.h" extern gpio_typedef* led_port[ledn]; extern const uint16_t led_pin[ledn]; [...] void mx_led_init(led_typedef led); #endif /* __myconfig_h */ then, in mydriverconfig.c
/* includes ------------------------------------------------------------------*/ #include "mydriverconfig.h" [...] void mx_led_init(led_typedef led) { [...] } then, in myapplications.h
#ifndef __myapplications_h #define __myapplications_h #ifdef __cplusplus extern "c" { #endif #include "stm32f0xx_hal.h" typedef enum { led1 = 0, led_green = led1 } led_typedef; [...] void led_on(led_typedef led); #endif /* __myapplications_h */ and finaly in myapplications.c
#include "myapplications.h" #include "mydriverconfig.h" gpio_typedef* led_port[ledn] = {led1_gpio_port}; const uint16_t led_pin[ledn] = {led1_pin}; code not perfect because there still circular includes : stm32f0xx_hal.h compiling well.
Comments
Post a Comment