Re: Performance warning
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 04/19/04
- Next message: Alexander Nickolov: "Re: How to downcast?"
- Previous message: Timo Kunze: "How to downcast?"
- In reply to: Mateusz Łoskot: "Performance warning"
- Next in thread: Simon Trew: "Re: Performance warning"
- Reply: Simon Trew: "Re: Performance warning"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Alexander Nickolov: "Re: How to downcast?"
- Previous message: Timo Kunze: "How to downcast?"
- In reply to: Mateusz Łoskot: "Performance warning"
- Next in thread: Simon Trew: "Re: Performance warning"
- Reply: Simon Trew: "Re: Performance warning"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|