Since we started using the ax_cxx_compile_stdcxx.m4
macro we’ve been passing [noext]
to indicate that we don’t want to use an extended mode, i.e GNU extensions. Speaking to Cory he clarified that the intention was to “require only vanilla c++11 and turn off extension support so they would fail to compile”.
However in the codebase we are currently making use of some GNU extensions. We should either remove there usage, or at least amend our CXX compiler checks. I’d prefer the former.
anonymous structs
0./prevector.h:153:9: warning: anonymous structs are a GNU extension [-Wgnu-anonymous-struct]
1 struct {
This is fixed in https://github.com/bitcoin/bitcoin/commit/b849212c1ec01cc8633b8cdcd390da9b1051be0d.
variadic macros
0./undo.h:57:50: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
1 ::Unserialize(s, VARINT(nVersionDummy));
This is taken care of in #18087.
The LOG_TIME_*
macros introduced in #16805 make use of a GNU extension.
0In file included from validation.cpp:22:
1./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
2 BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__)
3 ^
4./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
5./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
6./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
7./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
8./logging/timer.h:101:92: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
9 BCLog::Timer<std::chrono::seconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__)
10 ^
116 warnings generated.
This is fixed in 081a0ab64eb442bc85c4d4a4d3bc2c8e97ac2a6d and 612e8e138b97fc5ad2f38847300132a8fc423c3f.
prevention
To ensure that usage doesn’t creep back in we can add -Wgnu
to our compile time flags, which will make Clang warn whenever it encounters GNU extensions.
This would close #14130.
Also related to #17230, where it’s suggested we use a GNU extension, the gnu::pure
attribute.