Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Warning :suggest parentheses around assignment used as truth value

Warning :suggest parentheses around assignment used as truth value
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2008
Status: Offline
Reply With Quote
Jan 9, 2009, 12:15 AM
 
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..
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jan 9, 2009, 01:13 AM
 
You didn't mention this for-loop in your post.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Nov 2005
Location: Seattle, WA, USA
Status: Offline
Reply With Quote
Jan 9, 2009, 12:23 PM
 
It's with this:

Code:
if (handle_ =dlopen(....))
Either you meant to use == instead of =, or (if you really do want an assignment), the compiler just wants you to wrap it in another set of parenthesss to be safe. Basically, the parentheses that are already around the assignment don't count: they're part of the conditional statement you're using. Try rewriting both conditions as:

Code:
if ((handle_ =dlopen(...)))
and you should be good to go.

Any ramblings are entirely my own, and do not represent those of my employers, coworkers, friends, or species
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2