Skip to main content
pk84
Associate III
October 20, 2022
Solved

undeclared (first use in this function)...

  • October 20, 2022
  • 18 replies
  • 15791 views

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 

This topic has been closed for replies.
Best answer by pk84

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

18 replies

MM..1
Super User
October 20, 2022

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

pk84
pk84Author
Associate III
October 20, 2022

here:

0693W00000UoS7jQAF.png

Bob S
Super User
October 20, 2022

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.

pk84
pk84Author
Associate III
October 21, 2022

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

MM..1
Super User
October 21, 2022
I see it on github line 234 ... , but this all is simple C rules .
Senior
October 21, 2022

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.

pk84
pk84Author
Associate III
October 21, 2022

.

Senior
October 21, 2022

I think it's in stm32h745i_discovery_lcd.h, line 234: "extern BSP_LCD_Ctx_t Lcd_Ctx[];"

then he calls his .h in his .c file

pk84
pk84Author
Associate III
October 21, 2022

I have another similar question:

Why the compiler does not find lvgl.h, see screenshot below:

0693W00000UoXINQA3.png

Senior
October 21, 2022

You need to write #include "../lvgl/lvgl.h" because ../ means exit the folder where your .c is.

So you exit User then lvgl is in the same level

Senior
October 21, 2022

Ok maybe I don't see well the picture, there is an other possibility