0

As I understand, whenever the compiler is building in release mode, the macro NDEBUG is defined, while in debug mode it isn't. That is how assert knows when to work.

What I've noticed though is that with the MSVC compiler (2015), NDEBUG is never defined, regardless of the build mode.

Anyway, _DEBUG is defined. Is this macro standard C++ or some MSVC thing? Should I use it if I'm aiming for compatibility? Does it work with other compilers? (couldn't check) Thanks!

DeiDei
  • 10,205
  • 6
  • 55
  • 80
  • 2
    The only standard usage of a debugging macro is in `assert`, which uses `NDEBUG`. – interjay Dec 23 '15 at 17:01
  • 2
    Deciding whether to define `NDEBUG` is (intentionally, I believe) left up to you, not done automatically based on debug/release build. Quite a few people prefer to lead `assert`s active in release builds. – Jerry Coffin Dec 23 '15 at 17:05

0 Answers0