micro:bit v1 with yotta - removing build warnings
problem
Running yotta build
with the micro:bit v1 C tools produces screenfulls of depreceation warnings, such as:
warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
This makes it hard to find the error messages with the reason why the build failed.
solution
Tell the C++ compiler not to include depreceation warnings.
instructions
Add the compiler flag -Wno-deprecated
to the CMAKE_CXX_FLAGS_INIT options in the file toolchain.cmake
.
File location:
<project>/yotta_targets/bbc-microbit-classic-gcc/CMake/toolchain.cmake>/yotta_targets/bbc-microbit-classic-gcc/CMake/toolchain.cmake
Line before:
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} ${_CPU_COMPILATION_OPTIONS} -std=c++11 -fwrapv")
Line after adding flag:
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} ${_CPU_COMPILATION_OPTIONS} -std=c++11 -fwrapv -Wno-deprecated")
extra flags to suppress other distracting warning
While we’re on a roll, we can also suppress distracting warnings for array-bounds and misleading indentation by adding:
-Wno-array-bounds -Wno-misleading-indentation
to the same line.
endnote
There are layers of build tools used to transform your C code into a hex file that can be copied onto the micro:bit. I tried to understand and explain the toolchain in these blogs: