Re: bool vs. BOOL
- From: "Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx>
- Date: Tue, 16 Jan 2007 14:16:13 -0700
The first version should produce a warning if your warning settings are high
enough.
The reason is that the C compiler will automatcially generate code similar
to your second version and so you get a performance warning since code is
generated that may not be immediately obvious from looking at the source.
Either is ok as far as the resulting logic.
BTW, why not just
bool MyMethod()
{
return (bool)DeviceIoControl(...);
}
or (to eliminate the warning):
bool MyMethod()
{
return (DeviceIoControl(...) != 0);
}
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"VFaul" <VFaul@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:59B2C3BE-A4F7-4B09-ACA2-C0AF5F95EC1B@xxxxxxxxxxxxxxxx
I have many methods that return type bool. In the method I'm calling a
Microsoft method that returns BOOL. I want to return the result of the
Microsoft method as shown below.
bool MyMethod()
BOOL bOk = DeviceIoControl(...);
return (bool) bOk;
Is there a problem with return (bool) bOk;, or do I need to do the
following?
if (bOk)
return true;
else
return false;
I prefer not to change my method return type because of all the changes I
will have to make.
--
VFaul
.
- Follow-Ups:
- Re: bool vs. BOOL
- From: VFaul
- Re: bool vs. BOOL
- Prev by Date: Re: Combo Box
- Next by Date: Re: bool vs. BOOL
- Previous by thread: MFC GUI Front Office Development jobs - Chicago
- Next by thread: Re: bool vs. BOOL
- Index(es):
Relevant Pages
|