Discussion:
Showing its value rather than its representation
(too old to reply)
Jack
2007-05-11 15:00:44 UTC
Permalink
Hi,
In case I have the following
#define TRUE 1
#define FALSE 0
when I probe a variable, I don't see 'TRUE' or 'FALSE' but just 1 and 0
Is it possible to display TRUE or FALSE rather than 1 and 0/ also in
watches, locals and autos etc?
.NET 2002 Native C++ thanks
Jack
2007-05-11 15:04:58 UTC
Permalink
Title should be the other way round.
Sorry
Post by Jack
Hi,
In case I have the following
#define TRUE 1
#define FALSE 0
when I probe a variable, I don't see 'TRUE' or 'FALSE' but just 1 and 0
Is it possible to display TRUE or FALSE rather than 1 and 0/ also in
watches, locals and autos etc?
.NET 2002 Native C++ thanks
Ben Voigt
2007-05-16 13:22:45 UTC
Permalink
Post by Jack
Hi,
In case I have the following
#define TRUE 1
#define FALSE 0
when I probe a variable, I don't see 'TRUE' or 'FALSE' but just 1 and 0
Is it possible to display TRUE or FALSE rather than 1 and 0/ also in
watches, locals and autos etc?
No, the substitution is made before compilation starts, and not known to the
debugger. Besides, there could be (read: are) hundreds of different macros
defined as 1, how would the debugger know which to use?
Post by Jack
.NET 2002 Native C++ thanks
Nathan Mates
2007-05-16 15:16:21 UTC
Permalink
Post by Jack
#define TRUE 1
#define FALSE 0
when I probe a variable, I don't see 'TRUE' or 'FALSE' but just 1 and 0
Is it possible to display TRUE or FALSE rather than 1 and 0/ also in
watches, locals and autos etc?
Go read up on what #define really does. It effectively changes your
source code during the preprocessor (i.e. first) phase. The compiler
doesn't see 'TRUE' or 'FALSE', it sees 1 or 0. This is the design of
C/C++. If, however, you were to use an enum for these values, the
debugger stands a better chance of showing it. However, if the enum is
stored into a variable w/o that enum's type (and a lot of system
headers do this), then the type is lost.

Nathan Mates

--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
P.GopalaKrishna
2007-06-18 17:33:00 UTC
Permalink
Hello,

One workaround is to use Enums. Debugger will show the member names instead
of values.

Perhaps you might want to use Enums in debug builds to display their names
and #defines in release build.

All the best.

P.Gopalakrishna
http://www.geocities.com/krishnapg/
Post by Jack
Hi,
In case I have the following
#define TRUE 1
#define FALSE 0
when I probe a variable, I don't see 'TRUE' or 'FALSE' but just 1 and 0
Is it possible to display TRUE or FALSE rather than 1 and 0/ also in
watches, locals and autos etc?
..NET 2002 Native C++ thanks
Loading...