Page 1 of 1

Invalid initializers used in esp-idf demos

Posted: Tue Apr 22, 2025 8:06 pm
by justinmreina
Hi,
Your demos are using zero-initializers which is not supported by your tool yet -

Issue:
Example:

Zero Initializer Example.png
generic_gpio: gpio_example_main.c
Zero Initializer Example.png (109.76 KiB) Viewed 8532 times

Yikes! This is why I also use memset for explicit initialization, and leave the declaration explicitly uninitialized to support this -

My Pref:

Code: Select all

MyStruct example_struct;

//Init
memset(&example_struct, 0x00, sizeof(MyStruct));

Request:
  • Can we update the esp-idf to valid C17 initializers, or update the ESP-IDF to C23?


Thank you guys for your time, and for this tool! Enjoying my work here

Re: Invalid initializers used in esp-idf demos

Posted: Wed Apr 23, 2025 2:28 am
by Sprite
We use GCC, and the empty initializer being valid has been a GCC extension since forever. GCC will complain about it not being in the C specs if you ask it to be really pedantic, but esp-idf is not set to that mode, so it just happily does what you expect it to do even in C17 mode.

Re: Invalid initializers used in esp-idf demos

Posted: Wed Apr 23, 2025 4:27 am
by justinmreina
Interesting!

Thanks for the detail Sprite, I will be in review I am learning a lot here now

Best,
Justin

Re: Invalid initializers used in esp-idf demos

Posted: Wed Apr 23, 2025 4:30 am
by justinmreina
I have also had zero-initializers bug out in the past, on a few different platforms - unexpectedly. This is why I strictly employ memset() now for structure & array initializations

Back in a few