-Werror=missing-braces
Posted: Sat Jun 01, 2019 11:44 am
Working to port a graphical framework for ESP32-IDF. There is a designer tool under Windows similar to Qt-designer to assemble a GUI with export feature to Eclipse projects. Language in pure C.
In the framework there is a structure like this:
This structure is initialized with code snippet like this:
Unfortunately initialization above doesn't compile in ESP32 IDF. Error is missing braces around initializer [-Werror=missing-braces].
To get around I could add two more brace pairs to pass the IDF compiler. Code as below will compile in IDF.
But the problem is that, there are many places in the whole project requires WidgetSlots, and the code is generated by the Windows designer tool. So this is really out of my control to change every single brace pair to triple brace pairs everywhere in the project.
Another peculiar thing is, single brace initialization is working in ESP32 arduino. I am wondering if there is any switch or standard that I can apply to Cross GCC in ESP32 IDF such that initialization with single brace pair works?
Look forward to any suggestion.
John
In the framework there is a structure like this:
Code: Select all
typedef struct WidgetSlots
{
union
{
void(*Table[3])(void *context);
struct
{
// Pointers to slot functions
void(*Fcn_A)(void *context);
void(*Fcn_B)(void *context);
void(*Fcn_C)(void *context);
};
};
} WidgetSlots;
Code: Select all
static void Widget_Fcn_A(void *context)
{
//pending
}
static void Widget_Fcn_B(void *context)
{
//pending
}
static void Widget_Fcn_C(void *context)
{
//pending
}
void setup() {
// put your setup code here, to run once:
static WidgetSlots s_Raised__Slots = {
(void(*)(void *))Widget_Fcn_A,
(void(*)(void *))Widget_Fcn_B,
(void(*)(void *))Widget_Fcn_C,
};
}
To get around I could add two more brace pairs to pass the IDF compiler. Code as below will compile in IDF.
Code: Select all
// put your setup code here, to run once:
static WidgetSlots s_Raised__Slots = {{{
(void(*)(void *))Widget_Fcn_A,
(void(*)(void *))Widget_Fcn_B,
(void(*)(void *))Widget_Fcn_C,
}}};
Another peculiar thing is, single brace initialization is working in ESP32 arduino. I am wondering if there is any switch or standard that I can apply to Cross GCC in ESP32 IDF such that initialization with single brace pair works?
Look forward to any suggestion.
John