Solved

warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

Posted on 2006-11-27
4
8,219 Views
Last Modified: 2013-11-20
Hi guys,

Got this warning:

warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)


Want to tidy it up, here's the line affected:


bool bResult = pDlg->CB_IsOurCustomBrowser();




What would I need to do?


Cheers!
0
Comment
Question by:Cyber-Drugs
4 Comments
 
LVL 30

Accepted Solution

by:
Axter earned 300 total points
ID: 18021613
Hi Cyber-Drugs,
> What would I need to do?

Try the following:
bool bResult = pDlg->CB_IsOurCustomBrowser()?true:false;

David Maisonave (Axter)
Cheers!
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 200 total points
ID: 18021631
What is return type of CB_IsOurCustomBrowser? If this is int or BOOL, this warning is shown, because int is casted to bool. Notice that BOOL is defined as int32 value, and bool is one byte. There are three ways to correct this:

BOOL bResult = pDlg->CB_IsOurCustomBrowser();

bool bResult = (pDlg->CB_IsOurCustomBrowser() != 0);

bool bResult = (bool)pDlg->CB_IsOurCustomBrowser();
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18021653
Hi guys,

All of the solutions you posted worked, cheers! :)
0
 
LVL 2

Expert Comment

by:piyush_soni
ID: 21585849
This being said, I was just wondering, what would be the most efficient way to do this? No points ...just reply if you know and want to ....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 85
List out all word 7 257
Change owner from userA to server Local Administrators 7 59
withoutTen challenge 14 99
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now