Author Topic: NDEBUG and Release Build target  (Read 4772 times)

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
NDEBUG and Release Build target
« on: July 27, 2007, 05:18:04 pm »
Hi,

I frequently use assert() in my code development and was surprised when I got asserts in my Release build.
I guess I was expecting NDEBUG to be defined by default when building a Release build.
This is easy enough to fix on a project basis with Project->Build options->Release-># defines tab.
However, I would like to set this globally for all my Release builds.
In Settings->Compiler and debugger settings->Global compiler settings, I don't see how to distinguish Debug and Release targets.

Am I overlooking something?

Thanks.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5215
Re: NDEBUG and Release Build target
« Reply #1 on: July 27, 2007, 06:52:51 pm »
our project wizards probably should take this issue into account.
will assert be gone with NDEBUG in all compilers, or is it different per compiler (GCC, MS, ...)

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: NDEBUG and Release Build target
« Reply #2 on: July 27, 2007, 07:31:52 pm »
will assert be gone with NDEBUG in all compilers, or is it different per compiler (GCC, MS, ...)

Assert() is brought in with 'include <cassert>' (or <assert.h> in c).
It is a standard c function (or maybe macro in some implementations), so I assume that compliant C++ compilers support it.
By default the MS Visual C 6 IDE defines NDEBUG when building a Release version.
This is what I was expecting - or at least as a user option.
Thanks,

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: NDEBUG and Release Build target
« Reply #3 on: July 27, 2007, 10:50:52 pm »
Yep, it's a standard feature that should probably be set up by the wizards.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."