Closed AlwaysPS closed 1 year ago
Use #pragma GCC diagnostic
thing to push a context and disable the error/warning.
Use
#pragma GCC diagnostic
thing to push a context and disable the error/warning.
I don't think that will work. g++
(which follows the standard faithfully at this issue) does not allow this syntax at all.
Consider the following simple program test.cpp
:
int main()
{
static const char *const data[] = {
[0b01] = "0",
[0b00] = "1"
};
}
g++ test.cpp
will simply give the following error message:
test.cpp: In function 'int main()':
test.cpp:6:5: sorry, unimplemented: non-trivial designated initializers not supported
6 | };
| ^
test.cpp:6:5: sorry, unimplemented: non-trivial designated initializers not supported
On the other hand, Clang does support this syntax (as an extension). One temporary workaround is just to switch the compiler (which is the default c++
) to Clang.
Huh, TIL. Can you switch to using Clang?
If you're on macOS, then using AppleClang (the xcode command-line tools provided one) is the ideal.
In this case it's just a bad error message by GCC. Swapping the array initializers so they're in-order works fine. Still an extension but.. hey, who cares.
int main()
{
static const char *const data[] = {
[0b00] = "1",
[0b01] = "0"
};
}
Alternatively, just use Clang or have them as a comment next to each entry in the array.
FYI, we now test commits with GCC on Ubuntu 22.04 https://github.com/lifting-bits/remill/pull/672
I'll close this, but please reopen if you still have issues. Thank you!
There are some heavy uses of designated initializations in
remill/Arch/AArch32/Decode.cpp
. For example, from line 1479:The thing is, designated initializations are introduced in C99, but are never a part of standard C++. This piece of code is preventing me from compiling from the source (with g++ 9.4.0).