-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Version info:
Pico-SDK develop
branch (5592322)
arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
Steps to reproduce:
Get the pico-examples
repository
Rename either of the binary_info
examples to have a .cpp
extension and update the corresponding CMakeLists.txt
Build that example:
In file included from /pico/pico-sdk/src/common/pico_binary_info/include/pico/binary_info.h:30,
from /pico/pico-examples/binary_info/hello_anything/hello_anything.cpp:9:
/pico/pico-examples/binary_info/hello_anything/hello_anything.cpp: In function 'int main()':
/pico/pico-examples/binary_info/hello_anything/hello_anything.cpp:15:13: error: designator order for field '_binary_info_named_group::flags' does not match declaration order in 'const _binary_info_named_group'
15 | bi_decl(bi_program_feature_group(0x1111, 0, "UART Configuration"));
| ^~~~~~~~~~~~~~~~~~~~~~~~
/pico/pico-examples/binary_info/hello_anything/hello_anything.cpp:16:13: error: designator order for field '_binary_info_named_group::flags' does not match declaration order in 'const _binary_info_named_group'
16 | bi_decl(bi_program_feature_group(0x1111, 1, "Enabled Interfaces"));
| ^~~~~~~~~~~~~~~~~~~~~~~~
C++ has stricter requirements for designated initialisers: cppref
Note: out-of-order designated initialization, nested designated initialization, mixing of designated initializers and regular initializers, and designated initialization of arrays are all supported in the C programming language, but are not allowed in C++.
This can be resolved by changing the __bi_named_group
macro so flags
and group_tag
are initialised in the same order they are declared in the _binary_info_named_group
structure:
diff --git a/src/common/pico_binary_info/include/pico/binary_info/code.h b/src/common/pico_binary_info/include/pico/binary_info/code. h
index 63239a9..b7fedc9 100644
--- a/src/common/pico_binary_info/include/pico/binary_info/code.h
+++ b/src/common/pico_binary_info/include/pico/binary_info/code.h
@@ -156,8 +156,8 @@ static const struct _binary_info_named_group __bi_lineno_var_name = { \
.tag = _parent_tag, \
},\
.parent_id = _parent_id, \
- .group_tag = _group_tag, \
.flags = _flags, \
+ .group_tag = _group_tag, \
.group_id = _group_id, \
.label = _label \
}