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

前端 未结 4 1064
梦毁少年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条回答
  •  梦毁少年i
    2021-02-20 04:04

    If you look at the project settings of your IDE, you will see that those macros are actually manually defined there, they are not automatically defined by the compiler. In fact, there is no way for the compiler to actually know if it's building a "debug" or "release", it just builds depending on the flags provided to it by the user (or IDE).

    You have to make your own macros and define them manually, just like the IDE does for you when creating the projects.

提交回复
热议问题