|
Boost Users : |
From: abir basak (abirbasak_at_[hidden])
Date: 2006-12-20 00:16:16
Sebastian Redl wrote:
> Andrew Holden wrote:
>> Actually, it will. The versions of assert that I have seen will print
>> the complete expression that failed before they stop the program. This
>> will include the string.
>>
> My mistake. I thought the post was in answer to the second issue the
> author presented, that of printing debug messages.
>
> Sebastian Redl
For the second problem, i.e. printing a debug only message , may be a
simple solution is a macro like,
#ifdef _DEBUG
#define DEBUG_PRINT(msg) \
std::cerr << "DEBUG: " << msg << std::endl \
<<"("<<__FUNCTION__<<") "<<std::endl;
#else
#define DEBUG_PRINT(msg) do {} while(0);
#endif
But it is only too primitive one. as it lacks functionality in terms
1) not cross platform , as _DEBUG is not a standard macro.
2) it doesn't allow to evaluate an expression, only can print a string,
that to only ascii. If C++ supports variable number of args in macro
like C, I could have written it in terms of printf. But again, in that
case type safety is important, as a statement like
DEBUG_PRINT("my i is %i\n",i++) should not be allowed.
-- Abir Basak, Member IEEE Software Engineer, Read Ink Technologies B. Tech, IIT Kharagpur email: abir_at_[hidden] homepage: www.abirbasak.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net