Hi all,
After a terrible time setting up NCS v2.4.0 (the Nordic Connect tool on Mac does NOT set the environment up properly at all currently, by the way, so I've spent 4 hours trying to set that up properly) I've found that something within the Nordic toolset is downgrading the C++ standard used to -std=c++11. You can see this from the below:-
[build] FAILED: CMakeFiles/app.dir/REDACTED/herald-for-cpp/herald/src/datatype/base64_string.cpp.obj [build] ccache /opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++ -DCONFIG_APP_LOG_LEVEL=4 -DHERALD_LOG_LEVEL=4 -DHERALD_MEMORYARENA_MAX=4096 -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/REDACTED/herald-for-cpp/herald-venue-beacon/../herald/include -I/opt/nordic/ncs/v2.4.0/nrf/drivers/mpsl/clock_control -I/opt/nordic/ncs/v2.4.0/zephyr/include -I/REDACTED/herald-for-cpp/herald-venue-beacon/build/zephyr/include/generated -I/opt/nordic/ncs/v2.4.0/zephyr/soc/arm/nordic_nrf/nrf52 -I/opt/nordic/ncs/v2.4.0/zephyr/lib/libc/newlib/include -I/opt/nordic/ncs/v2.4.0/zephyr/soc/arm/nordic_nrf/common/. -I/opt/nordic/ncs/v2.4.0/zephyr/subsys/bluetooth -I/opt/nordic/ncs/v2.4.0/zephyr/subsys/settings/include -I/opt/nordic/ncs/v2.4.0/nrf/include -I/opt/nordic/ncs/v2.4.0/nrf/lib/multithreading_lock/. -I/opt/nordic/ncs/v2.4.0/nrf/subsys/bluetooth/controller/. -I/opt/nordic/ncs/v2.4.0/nrf/tests/include -I/opt/nordic/ncs/v2.4.0/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx -I/opt/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx/drivers/include -I/opt/nordic/ncs/v2.4.0/modules/hal/nordic/nrfx/mdk -I/opt/nordic/ncs/v2.4.0/zephyr/modules/hal_nordic/nrfx/. -I/opt/nordic/ncs/v2.4.0/modules/debug/segger/SEGGER -I/opt/nordic/ncs/v2.4.0/modules/debug/segger/Config -I/opt/nordic/ncs/v2.4.0/zephyr/modules/segger/. -I/opt/nordic/ncs/v2.4.0/modules/crypto/tinycrypt/lib/include -I/opt/nordic/ncs/v2.4.0/nrfxlib/mpsl/include -I/opt/nordic/ncs/v2.4.0/nrfxlib/mpsl/include/protocol -I/opt/nordic/ncs/v2.4.0/nrfxlib/softdevice_controller/include -g -std=gnu++17 -fno-strict-aliasing -Os -fcheck-new -std=c++11 -fno-exceptions -fno-rtti -imacros /REDACTED/herald-for-cpp/herald-venue-beacon/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs --sysroot=/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /opt/nordic/ncs/v2.4.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/REDACTED/herald-for-cpp/herald-venue-beacon=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.4.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.4.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -MD -MT CMakeFiles/app.dir/REDACTED/herald-for-cpp/herald/src/datatype/base64_string.cpp.obj -MF CMakeFiles/app.dir/REDACTED/herald-for-cpp/herald/src/datatype/base64_string.cpp.obj.d -o CMakeFiles/app.dir/REDACTED/herald-for-cpp/herald/src/datatype/base64_string.cpp.obj -c /REDACTED/herald-for-cpp/herald/src/datatype/base64_string.cpp
I suspect this is what has also caused this issue reported by someone else recently: nRFConnect Examples fail to build with C++17
Although my CMake script is specifying C++17 (not GNU), as you can see from the above the Nordic tools are somehow rewriting this to -std=gnuc++17 and -std=c++11 at the same time. (Even though I'm originally directing CMake to use -stc=c++17 via the usual CMAKE vars). This causes my build to fail as I use c++17 code in Herald.I'm doing this on a mac at the moment but I doubt running this from elsewhere will change anything.
My CMake script hasn't changed in over 2 years so I'm confident it's an SDK issue.
Not a great user experience though. I have to waste a full day every time I upgrade NCS. Routinely. Like clockwork. Every. Single. Time. If this happens again I'm going to just drop the Nordic SDK and try just OSS Zephyr.
I need to get this working as our COVID-19 digital contact tracing library (Herald) needs to be programmed onto 150 nRF52832 based devices before August so we can conduct tests and trials. Not to mention other apps we have around health monitoring wearables and bluetooth mesh devices for potential use in hospitals.
I'm going to try downgrading to v2.2.0 then further back as I need to go. Please though fix this in the Nordic SDK and include a C++17 example in your test CI scripts before an SDK is released. This should have been caught in QA.
Thanks.