开发者

Where does the -DNDEBUG normally come from?

开发者 https://www.devze.com 2022-12-13 13:02 出处:网络
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.

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 makef开发者_C百科iles.


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).


It is really difficult to answer this since you didn't specify the build system you are using. If you're using Autoconf, then either the user is expected to put -DNDEBUG in CPPFLAGS manually (or perhaps you were setting it from a CONFIG_SITE file that has changed), or the configure.ac file might set up a custom variable for setting NDEBUG, or configure.ac may invoke AC_HEADER_ASSERT, in which case adding --disable-assert to the invocation of configure will define NDEBUG in config.h. There are lots of ways it can happen.


In my experience, -DNDEBUG has been passed manually, i.e. the makefiles have been written in such a way that the flag is passed when building in release mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消