Warning :suggest parentheses around assignment used as truth value

Joined
Oct 27, 2008
Messages
13
Reaction score
0
Points
1
Hi
I am using this snippet of code

void * handle_;

if (handle_ =dlopen("/System/Library/Frameworks/DiskArbitration.Framework/Versions/A/DiskArbitration",RTLD_NOW))
{
printf("............");

}
else if (handle_ =dlopen("/System/Library/PrivateFrameworks/DiskArbitration.Framework/Versions/A/DiskArbitration",RTLD_NOW))
{
printf(".................");
}

But i am getting the warning :
"suggest parentheses around assignment used as truth value" for the first line i,e the for the "for" loop....can somebody help me to get rid of this warning..:[
 
Joined
Mar 15, 2007
Messages
161
Reaction score
4
Points
18
Your Mac's Specs
17" MacBook Pro, 2.33GHz C2D, 2GB RAM
Two ways to handle this:

1) Change the line(s) to make the assignment result's participation in a boolean expression explicit, i.e. "if ((bool)(handle_ = dlopen()) == true)". Actually just the extra pair of parens would suppress the warning, but that would be ugly code in my opinion ... it's better to demonstrate that you are deliberately making an assignment and then comparing the result to a boolean value.

2) If you prefer the original, more terse version of the code, you can go into the Build options on the target executable, search for "parentheses" under GCC Warnings, and unselect that checkbox for all configurations. (This is for Xcode 3.1.1, but I assume that earlier versions probably had a similar build option.)
 
Joined
Jan 7, 2009
Messages
4
Reaction score
0
Points
1
Location
USA
Your Mac's Specs
SpaceTeaBoo
Medical Education questions

Hi

I need some help. Is here anybody who studies at Medic school or a college or may be university. May be somebody knows some sites of medic school material
I need some texts about health care, different catigories ex mental health, women health and other. I should make my study soon. Please help me to find some info. And it should be information that google cant find, cos my teacher kill me for that.

Thanks for help
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top