英文:
Zephyr RTOS: Enabling C++ Exceptions
问题
I'm trying to enable C++ Exceptions for Zephyr (Version 3.2.99). The documentation only states, that CONFIG_EXCEPTIONS must be enabled.
Where do I have to enable cpp exceptions, so that -fno-exceptions
is not passed?
I enabled it in the CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
set(BOARD xiao_ble)
find_package(Zephyr)
project(my_project)
# ...
target_sources(app PRIVATE
src/main.cpp
# ...
)
target_compile_options(app PRIVATE -fexceptions)
and in the KConfig (prj.conf):
# CPP
CONFIG_CPLUSPLUS=y
CONFIG_EXCEPTIONS=y
# ...
but still a -fno-exceptions
is passed when building the project.
英文:
I'm trying to enable C++ Exceptions for Zephyr (Version 3.2.99). The documentation only states, that CONFIG_EXCEPTIONS must be enabled.
Where do I have to enable cpp exceptions, so that -fno-exceptions
is not passed?
I enabled it in the CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
set(BOARD xiao_ble)
find_package(Zephyr)
project(my_project)
# ...
target_sources(app PRIVATE
src/main.cpp
# ...
)
target_compile_options(app PRIVATE -fexceptions)
and in the KConfig (prj.conf):
# CPP
CONFIG_CPLUSPLUS=y
CONFIG_EXCEPTIONS=y
# ...
but still a -fno-exceptions
is passed when building the project.
答案1
得分: 0
I didn't read the CMake output properly. The KConfig in the question produces the following warning: warning: EXCEPTIONS (defined at subsys/cpp/Kconfig:76) was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: LIB_CPLUSPLUS (=n).
This is because enabling the CONFIG_EXCEPTIONS
requires CONFIG_LIB_CPLUSPLUS
to be enabled and CONFIG_NEWLIB_LIBC_NANO
to be disabled, as stated in the KConfig options documentation. After adding these two configurations to the prj.conf
file like this:
# CPP
CONFIG_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_LIB_CPLUSPLUS=y
CONFIG_EXCEPTIONS=y
# ... any other configurations
exceptions can be thrown.
英文:
I didn't read the CMake output properly. The KConfig in the question produces the following warning: warning: EXCEPTIONS (defined at subsys/cpp/Kconfig:76) was assigned the value 'y' but got the value
'n'. Check these unsatisfied dependencies: LIB_CPLUSPLUS (=n).
This is because enabling the CONFIG_EXCEPTIONS
requires CONFIG_LIB_CPLUSPLUS
to be enabled and CONFIG_NEWLIB_LIBC_NANO
to be disabled, as stated in the KConfig options documentation. After adding these two configurations to the prj.conf
file like this:
# CPP
CONFIG_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_LIB_CPLUSPLUS=y
CONFIG_EXCEPTIONS=y
# ... any other configurations
exceptions can be thrown.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论