Re: Performance warning

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 04/19/04


Date: Sun, 18 Apr 2004 20:17:09 -0700

Boolean is 8 bits - corresponds to unsigned char. OTOH, BOOL
is 32 bits - corresponds to int. The warning underscores the fact
the compiler has to generate code to check if a 32 bit entity (the
boolean result) is zero and fit it into 8 bits 0 or 1 - just like the C++
bool type. This constitutes a performance penalty, since a "boolean"
value in C/C++ is any int (32 bit on 32-bit platforms) value - zero
is false, non-zero is true. This code won't be emitted if you use the
32 bit type.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Mateusz Łoskot" <antispam@see.my.signature> wrote in message
news:nQDgc.11573$N9.5733@news.chello.at...
> Hi,
>
> I have a question regarding the warning message below:
>
> MyCom.cpp(539) : warning C4800: 'boolean' : forcing value to bool 'true'
> or 'false' (performance warning)
> MyCom.cpp(561) : warning C4800: 'boolean' : forcing value to bool 'true'
> or 'false' (performance warning)
>
> In my IDL file with MyCom interfaces definitions, and also
> in MyCom.h and MyCom.cpp I use in this example type of boolean, not BOLL
> and not bool ;-)
> Strange, but it's some test.
>
> As you can see, I got the interesting message with warning
> about possible performance (increase ? decrease ? ;-)))
>
> Could anyone explain me what does it mean "performance warning" and
> how it influences the performance if I don't change my
> boolean to bool ?
>
> The reason I ask is only that I'm a little interested in such aspects.
>
> Kind regards
>
> -- 
>
> Mateusz Łoskot
> mateusz at loskot dot net


Relevant Pages

  • Help!! About MySQL and VC6
    ... When I try to compile the program, warning occurs. ... forcing value to bool 'true' or 'false' (performance warning) ... was truncated to '255' characters in the debug information ...
    (comp.lang.cpp)
  • FinalReleaseComObject and RCWs
    ... BOOLEAN GetLocalTime(unsigned char ... WARNING: Cleaning up a native com object from the finalizer thread, ... which may result in a memory leak under Windows CE. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: bool vs. BOOL
    ... The first version should produce a warning if your warning settings are high ... bool MyMethod() ... Microsoft method that returns BOOL. ... BOOL bOk = DeviceIoControl; ...
    (microsoft.public.vc.mfc)
  • Re: gratuitous gcc warnings: unused function arguments?
    ... > I'm not sure what is required to disable this warning, ... The second error message is only generated when GCC thinks it ... someone else (hopefully a GCC expert/language pedant :-) second guess whether ... bool warn_unused_variable; ...
    (freebsd-current)
  • Re: array_search troubles
    ... The warning states: ... Boolean value which evaluates to FALSE, ... echo "Match found\n"; ...
    (comp.lang.php)