mirth-lang/mirth

"error: suggest braces around initialization of subobject"

akrmn opened this issue · 1 comments

akrmn commented

I'm currently getting this error while trying to build the compiler [1].
This might be due to some quirk of my system (macOS, just updated to 11.0.1). I'm not sure whether the fix is to add the suggested braces or to silence the warning. I found this thread on the llvm site, but I'm not sure if it's the same case that we have here.

[1]

> make
gcc -std=c99 -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Werror -pedantic -o bin/mirth0 bin/mirth0.c
bin/mirth0.c:74:47: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
static volatile value_t stack [STACK_SIZE] = {0};
                                              ^
                                              {}
bin/mirth0.c:80:44: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
static volatile cell_t heap [HEAP_SIZE] = {0};
                                           ^
                                           {}
2 errors generated.
make: *** [bin/mirth0] Error 1

Hmm. Looking into this, it seems this warning is generated by (some versions of) gcc/clang compilers, but= {0} is the standard (idiomatic?) way to initialize array/struct memory to 0 in C, regardless of its depth.

My preferred solution right now would be to ignore the warning by adding -Wno-missing-braces in the Makefile. Do want to do the honors of opening a PR, or shall I? :-)

Long term, the plan is to stop generating C altogether.