我正在积极学习C ++,并且正在使用以下cmake意见对我的代码进行清理,并想知道是否有任何方法可以通过编程方式检查const correctness
。如果我的代码不是const正确的,那么编译器会抛出错误吗?
有什么方法可以检查吗?由于我是C ++的新手,所以我迅速阅读了规则并感到困惑。
##############################################################################
# Options
# We use a cached string variable instead of the standard (boolean) OPTION
# command so that we can default to auto-detecting optional depencies, while
# still providing a mechanism to force/disable these optional dependencies, as
# prescribed in http://www.gentoo.org/proj/en/qa/automagic.xml
option (ENABLE_ASAN "Enable Address Sanitizer" ON)
option (ENABLE_UBSAN "Undefined Behaviour Sanitizer" ON)
# Reference code from https://github.com/apitrace/apitrace/blob/master/CMakeLists.txt
# Enable Address Sanitizer
if (ENABLE_UBSAN)
set (_FLAGS "-fsanitize=undefined")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_FLAGS}")
endif ()
if (ENABLE_ASAN)
set (_FLAGS "-fsanitize=address")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_FLAGS}")
endif ()