I
isanbard
Hi all,
I'd like to do something like this:
#include <ostream>
std:stream cnull(0);
#ifdef NDEBUG
#define DOUT cnull
#else
#define DOUT std::cerr
#endif
int main()
{
// ...
DOUT << "This is a debug message\n";
// ...
}
My question is, is the above okay? That is, is passing 0 in for the
stream buffer okay and portable and won't make things crash?
As an added bonus, I'd like to have all cnull symbols and the debug
string removed from the resulting executable when NDEBUG is defined.
Will this happen with the above?
Or is there a better way?
Thanks!
-bw
I'd like to do something like this:
#include <ostream>
std:stream cnull(0);
#ifdef NDEBUG
#define DOUT cnull
#else
#define DOUT std::cerr
#endif
int main()
{
// ...
DOUT << "This is a debug message\n";
// ...
}
My question is, is the above okay? That is, is passing 0 in for the
stream buffer okay and portable and won't make things crash?
As an added bonus, I'd like to have all cnull symbols and the debug
string removed from the resulting executable when NDEBUG is defined.
Will this happen with the above?
Or is there a better way?
Thanks!
-bw