Re: bool or BOOL in MFC projects



"David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in news:
#x9b7wpQIHA.536@xxxxxxxxxxxxxxxxxxxx:

How about using "!!", the "make boolean" operator:

#define truth(x) (!!(x))
#define TRUTH(x) (!!(x))

Nice! But I'd have to assuage my conscience with

#define truth(x) ((bool)(!!(x)))
#define TRUTH(x) ((BOOL)(!!(x)))

The cast in truth is a no-op because !! returns bool already,
and the cast in TRUTH is unneeded because a bool can implicitly
be converted into an int (what BOOL is). Also, in C++ programs,
my conscience tells me to avoid C casts altogether. :)

Best regards
Wolfram
.



Relevant Pages