Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Warning :suggest parentheses around assignment used as truth value
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mystic_fm" data-source="post: 784792" data-attributes="member: 28538"><p>Two ways to handle this:</p><p></p><p>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.</p><p></p><p>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.)</p></blockquote><p></p>
[QUOTE="mystic_fm, post: 784792, member: 28538"] 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.) [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Warning :suggest parentheses around assignment used as truth value
Top