问题描述
我正在使用 CMake 在 Windows (Visual Studio) 以及 Linux 机器 (gcc) 上构建我的项目.我想将一些代码标记为仅调试",例如
I am using CMake for building my projects on Windows (Visual Studio) as well as on Linux machines(gcc). I'd like to mark some code as "debugging only", like with
#ifdef DEBUG
//some logging here
#endif
问题是:CMake调试"构建类型的所有平台上都有哪些编译器定义?DEBUG 好像不存在.(我只想在构建类型为 Debug 时进行日志记录或其他任何操作.)
The question is: what compiler definition is available on all platforms in the CMake "Debug" build type? DEBUG seems not to exist. (I want to have the logging or whatever only when the build type is Debug.)
推荐答案
CMake 默认将 -DNDEBUG 添加到 CMAKE_C_FLAGS_{RELEASE, MINSIZEREL} 中.因此,您可以使用 #ifndef NDEBUG.
CMake adds -DNDEBUG to the CMAKE_C_FLAGS_{RELEASE, MINSIZEREL} by default. So, you can use #ifndef NDEBUG.
这篇关于#ifdef DEBUG 与 CMake 独立于平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)