What predefined macro can be used to detect debug build with clang?

前端 未结 4 1011
梦毁少年i
梦毁少年i 2021-02-20 03:20

MSVC defines _DEBUG in debug mode, gcc defines NDEBUG in release mode. What macro can I use in clang to detect whether the code is being compiled for r

4条回答
  •  没有蜡笔的小新
    2021-02-20 03:56

    You can use the __OPTIMIZE__ flag to determine if optimization is taking place. That generally means it is not a debug build since optimizations often rearrange the code sequence. Trying to step through optimized code can be confusing.

    This probably is what those most interested in this question really are attempting to figure out.

提交回复
热议问题