Search code examples
c++makefilendebug

Where does the -DNDEBUG normally come from?


Our build system has somehow changed such that optimized builds are no longer getting the -DNDEBUG added to the compile line. I searched our makefiles and didn't find this.

Where does -DNDEBUG originate for most people and how might that have changed? Before we did have -DNDEBUG, and I don't think this was removed from any of our makefiles.


Solution

  • Since the compiler can't decide on its own when to add the NDEBUG define and when not to, the flag is always set by either the makefile or project file (depending on your build system).