| re: debug function -> noop
Gernot Frisch wrote:
[color=blue]
> "John Hunter" <jdhunter@ace.bsd.uchicago.edu> schrieb im Newsbeitrag
> news:m2smclcarq.fsf@mother.paradise.lost...
>[color=green]
>>In C++, what is the best what to define a function / macro /[/color]
>
> template
>[color=green]
>>which will print a string to std::cout if a flag is set, but[/color]
>
> generate
>[color=green]
>>no code otherwise. In my code I want to be able to do something[/color]
>
> like
>[color=green]
>>DEBUG_PRINT("some string");
>>
>>but I want to define DEBUG_PRINT in such a way that code is
>>conditionally generated.[/color]
>
>
> #ifdef _DEBUG
> #define DEBUG_PRINT(a) std::cout << (a)
> #else
> #define DEBUG_PRINT(a)
> #endif[/color]
I believe using the NDEBUG macro would be a bit more standard way to do
it. The standard does mention NDEBUG, but doesn't mention _DEBUG.
--
Peter van Merkerk
peter.van.merkerk(at)dse.nl |