[Os-project-managers] Fwd: Re: Question about BuildTools?

Horand Gassmann Horand.Gassmann at DAL.CA
Tue Nov 6 10:08:12 EST 2012


Hi guys,

ysterday I sent a message to the BuildTools people to help me clarify  
a minor detail I had some trouble with. I reproduce below my wuery to  
the list, followed by a response I got from Stefan, and then finally I  
have a further question for you guys based on Stefan's response.


----- My original query -----
Hi,

I am just experimenting with some build issues and am wondering if there
is a *nix equivalent to the Windows environment variables _DEBUG and
NDEBUG. These variables make it very convenient for me to put debug
statements into the code by hiding them behind

#ifdef _DEBUG
...
#endif

without having to worry about performance issues in the production code
--- the compiler filters all that out for me. But it seems that in the
unix world this is not available; the compiler command

g++ -g -O0 ...

does not set any environment variables that I can see. Is there anything
else I can do to duplicate the Windows functionality? Would I have to
write something into configure.ac?


----- Stefan's reply -----
Hi,

in the COIN-OR buildsystem, debug builds (from --enable-debug) are  
compiled without -DNDEBUG in the compiler flags, while default  
(optimized) builds are done with -DNDEBUG.
The latter leads to have NDEBUG defined when the C/C++ preprocessor is  
running.
So your debugging code should go into a #ifndef NDEBUG / #endif.

I think this is fairly standard behavior and not specific to Windows  
or COIN-OR.

There is nothing that defines _DEBUG, as far as I know. You can add  
this define by configuring with ADD_CFLAGS=-D_DEBUG and  
ADD_CXXFLAGS=-D_DEBUG.


----- My follow-up query for you -----

Do you think

#ifndef NDEBUG
...
#endif

is descriptive enough, or do you prefer

#ifdef _DEBUG
...
#endif

? In the latter case we would have to add the two environment  
variables to the build system, something which I hope would be easy to  
do. (Just to create a context for the query: It all has to do with  
ticket 14 and the really verbose print statements that I would like to  
reserve for debugging purposes only.)

Any thoughts?

Cheers

gus




More information about the Os-project-managers mailing list