Greetings,
We've run into issues while trying to get the nRFConnect v2.4.0 examples to build for a C++17 project. The problem is easy to replicate by:
- Create an example project for LLPM in VSCode/nRFConnect
- In KConfig enable C++ Support and select C++17
- Rename main.c to main.cpp
- Update CMakeLists.txt to include src/main.cpp
- Attempt a pristine build
- Observe Terminal Output
It looks like there are a number of issues (all fairly minor?) including:
- Designator order for struct initialization not matching declaration order
- Easy enough to reorder
- Poorly designed/unnecessary macros resulting in utilizing addresses of temporary arrays
- The macros just initialize an array of structures... so we can just use the standard C code way of doing that and eliminate multi-level macros
- Invalid C-style conversations from void* to typedef struct pointers
- For our project we can use the appropriate C++ style casts (static_cast or reinterpret_cast). I'm not sure how to make that C-compliant
- Note that there are a number of C-style casts to void* deep inside the macro-chain. This can hide some fairly nasty bugs like casting a value to void* instead of the intended pointer to the value.
It's not a huge deal to make the fixes, but it's fairly frustrating for example projects to not build out of the box. The "helper" macros make things worse since the identifying the real bug requires diving down multiple layers and reengineering the intent to make the example compile.
Please let me know if you're able to replicate this or have an easy solution I'm missed.
Thanks!