Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 61
Folder Comparison 12 54
Smart Camera scanning and reading information 3 106
Sed question 2 86
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

803 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