Solved

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

Posted on 2006-11-27
4
8,206 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

705 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

20 Experts available now in Live!

Get 1:1 Help Now