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

Kipp Martin kmartin at chicagobooth.edu
Mon Nov 12 01:51:22 EST 2012


Hi Gus:

I definitely think we should go with the standard

Do you think

#ifndef NDEBUG
...
#endif

>
> 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
>
>
> _______________________________________________
> Os-project-managers mailing list
> Os-project-managers at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/os-project-managers


-- 
Kipp Martin
Professor of Operations Research
and Computing Technology
Booth School of Business
University of Chicago
5807 South Woodlawn Avenue
Chicago, IL 60637
773-702-7456
kmartin at chicagobooth.edu
http://www.chicagobooth.edu/faculty/bio.aspx?person_id=12825325568
http://projects.coin-or.org/OS

Sent without Blackberry, Droid, iPhone, or any other
wireless device.
-- 


More information about the Os-project-managers mailing list