Where does the -DNDEBUG normally come from?

谁说我不能喝 提交于 2019-11-27 13:34:23

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!