Questions tagged [ndebug]

12 questions
42
votes
2 answers

What is the NDEBUG preprocessor macro used for (on different platforms)?

I'm interested in what purpose various platforms / compilers ("implementations") / frameworks assign to the the C and C++ preprocessor macro NDEBUG. The C as well as the C++ standard only mention this definition once, namely to control the behavior…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
29
votes
3 answers

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…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
24
votes
4 answers

How to enable assert in CMake Release mode?

CMake is being used to compile some C++ files. There are assert calls in the code. These calls are disabled in Release mode of CMake. It defines NDEBUG in Release mode, I guess. If I'm interested in having assert in Release mode of CMake, how do I…
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
17
votes
3 answers

cmake ignores -D CMAKE_BUILD_TYPE=Debug

I'm just trying to build a cmake project in debug-mode to enable asserts. I tried the following versions: cmake -D CMAKE_BUILD_TYPE:STRING=Debug -L ../../ cmake -DCMAKE_BUILD_TYPE:STRING=Debug -L ../../ cmake -DCMAKE_BUILD_TYPE=Debug -L…
ma0ho
  • 623
  • 1
  • 4
  • 17
5
votes
5 answers

How to override assert macro in C?

I want to create my own version of assert in which it does some log prints in case assert was called in NDEBUG mode. I tried to do the LD_PRELOAD trick and redefine the assert macro but it seems to ignore the macro definition completely and…
itayb
  • 139
  • 3
  • 10
1
vote
0 answers

OR-Tools; deactivating DCHECKS and defining NDEBUG

I'm a bit unexperienced using C++ or cmake and need some help using OR-Tools. The program runs and solves the problem. But when running the solver, there is a console output created that shows: W0913 20:23:00.688635 23528 lp_solver.cc:151]…
fnktb
  • 11
  • 2
1
vote
1 answer

Mixing NDEBUG - is it safe?

Consider a C++ header file compiled both in my_lib.a and in my_prog that links with my_lib.a. The library was compiled without NDEBUG, while my_prog - with NDEBUG. Would it result in ODR violation? What if my_lib.so is a shared library? Of course,…
Igor R.
  • 14,716
  • 2
  • 49
  • 83
1
vote
1 answer

Is there any way to make Rcpp stop defining NDEBUG?

Why does assert not work here? ^ Apparently, Rcpp has a habit of defining NDEBUG on its own, even if not defined by myself. m@m-X555LJ:~/wtfdir$ cat WTF.r #!/usr/bin/Rscript library(Rcpp) sourceCpp("WTF.cpp") m@m-X555LJ:~/wtfdir$ cat…
user4385532
0
votes
2 answers

Using #define NDEBUG give me errors in C++

If I define NDEBUG in the top of my main.cpp I get all this errors: 1> All outputs are up-to-date. 1>libcmt.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj) 1>libcmt.lib(invarg.obj) : error LNK2005:…
Danikaze
  • 193
  • 1
  • 8
0
votes
1 answer

shield (invalidate) assert in python

I want to invalidate the "assert" in my Python codes when I run it as a release edition. Consider that a lot of "assert" may be used in my files in the developing procedure, but I want to skip the compiling of "assert" to enhance the efficiency. Is…
Sean Lau
  • 11
  • 1
0
votes
1 answer

debug xap faster in performance than release xap?

WP8 app After debugging and releasing the app, I've tried to run the xap of both on different devices, apparently that the debug xap is way faster than the release xap. The method I used is by deploying the xap, not through VS12. If anyone would…
0
votes
2 answers

turning off DEBUG macros for a specific function (NDEBUG)

I am using the following macro for printing debug information that I found on the web. It works great. However, I would like to turn-off debug printing for function A when debugging function B, which calls function A. I tried #define NDEBUG function…
user151410
  • 776
  • 9
  • 22