解决方法:
在cmakelists.txt中添加设置:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
问题解决
下面是cmakelists.txt中的常见设置。
set(CPU_OPTIONS "${CPU_OPTIONS} -mthumb -mcpu=cortex-m0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CPU_OPTIONS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPU_OPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-use-cxa-atexit")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${LINKER_SCRIPT}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostartfiles")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
# optimizations (-O0 -O1 -O2 -O3 -Os -Ofast -Og -flto)
set(OPTIMIZATION_DEBUG "-Og")
set(OPTIMIZATION_RELEASE "-O2 -flto")
set(CMAKE_C_FLAGS_DEBUG "${OPTIMIZATION_DEBUG} -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${OPTIMIZATION_DEBUG} -g -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${OPTIMIZATION_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${OPTIMIZATION_RELEASE}")
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/jacke121/article/details/123255141
内容来源于网络,如有侵权,请联系作者删除!