Invalid initializers used in esp-idf demos

justinmreina
Posts: 71
Joined: Tue Jul 18, 2017 10:39 pm
Location: Snohomish, WAt
Contact:

Invalid initializers used in esp-idf demos

Postby justinmreina » Tue Apr 22, 2025 8:06 pm

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 8531 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

Sprite
Espressif staff
Espressif staff
Posts: 10593
Joined: Thu Nov 26, 2015 4:08 am

Re: Invalid initializers used in esp-idf demos

Postby Sprite » Wed Apr 23, 2025 2:28 am

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.

justinmreina
Posts: 71
Joined: Tue Jul 18, 2017 10:39 pm
Location: Snohomish, WAt
Contact:

Re: Invalid initializers used in esp-idf demos

Postby justinmreina » Wed Apr 23, 2025 4:27 am

Interesting!

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

Best,
Justin

justinmreina
Posts: 71
Joined: Tue Jul 18, 2017 10:39 pm
Location: Snohomish, WAt
Contact:

Re: Invalid initializers used in esp-idf demos

Postby justinmreina » Wed Apr 23, 2025 4:30 am

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

Who is online

Users browsing this forum: No registered users and 1 guest