cancel
Showing results for 
Search instead for 
Did you mean: 

undeclared (first use in this function)...

pk84
Senior

Hello,

I am going crazy, I always get the error that the structure Lcd_Ctx is not declared, while it is clearly declared (by including "stm32h750b_discovery_lcd.h").

With F3 I can find the structure declaration.

If I change the file from .c to .cpp the error is gone...

See screenshot below:

0693W00000UoQm6QAF.png 

1 ACCEPTED SOLUTION

Accepted Solutions

oh, now I see the problem, thank you.

In the 745 h-file the variable is declared with extern Lcd_Ctx, and in the 750 h-file with LcdCtx ...

0693W00000UoWqnQAF.png

View solution in original post

18 REPLIES 18
MM..1
Chief II

Sorry , but you dont show where you declare Lcd_Ctx not type , but object. Try show code part.

pk84
Senior

here:

0693W00000UoS7jQAF.png

Bob S
Principal

There should be a .h file with an "extern" declaration for that variable (maybe in stm32h750b_discovery_lcd.h). Make sure that you include that file in your lvgl_port_lcd.c file. If there isn't an "extern" declaration somewhere, you need to add one.

In following code there is no "extern" declaration, see link/screenshot below.

I just copied the files into my code, and if possible I don't want change something in these files.

Why do I need it in my code this "extern" but in the mentioned/linked code there is no "extern" declaration? How can I do it the same way?

https://github.com/lvgl/lv_port_stm32h745i_disco/blob/master/CM7/Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_lcd.h

0693W00000UoVrLQAV.png

MA4
Associate III

Hello, I think that it finds your structure but not your variable, in the file where you want to use your variable you must write extern BSP_LCD_Ctx_t Lcd_Ctx[LCD_INSTANCES_NBR] because the variable is not declare in the same file.

I see it on github line 234 ... , but this all is simple C rules .

yes, my C-basic knowledge will have gaps for sure... but the thing with these links I never really understood, or never found something that explains this understandable, so my devise is "learning by doing"...

I still not understand the difference between my file structure and the file structure of the origin code on github... and why the code on github does not need this "extern" declaration...

.

/** @addtogroup STM32H745I_DISCO_LCD_Exported_Variables
* @{
*/
extern const LCD_UTILS_Drv_t LCD_Driver;
extern DMA2D_HandleTypeDef hlcd_dma2d;
extern LTDC_HandleTypeDef  hlcd_ltdc;
extern BSP_LCD_Ctx_t       Lcd_Ctx[];