Xcode 4/LLVM Warning

Discussion in 'iOS Programming' started by idelovski, Oct 21, 2011.

  1. idelovski macrumors regular

    Joined:
    Sep 11, 2008
    #1
    I don't get it! I have just put Xcode 4 on Mac and I am already hating everything about it. OK, some of it may be me, but this is crazy:

    I have this warning - using result of assignment as condition without parentheses for this line:

    Code:
    if (retImage = [imgDatabase imageWithAddress:imgAddress returnCode:NULL])  {
    even though I have -Wno-idiomatic-parentheses in Other Warning Flags. Plus, I have this line in the same file, but the compiler is ok with it:

    Code:
    if (self = [super init])  {
    What is it that I'm missing here?
     
  2. lee.anderson, Oct 21, 2011
    Last edited: Oct 21, 2011

    lee.anderson macrumors regular

    lee.anderson

    Joined:
    Aug 28, 2006
    Location:
    UK
    #2
    If you actually are wanting to assign it in the if statement then put the entire line in an extra pair of parenthesis like this
    Code:
    if ((retImage = [imgDatabase imageWithAddress:imgAddress returnCode:NULL]))  {
     
  3. idelovski, Oct 21, 2011
    Last edited: Oct 21, 2011

    idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #3
    Does -Wno-idiomatic-parentheses serve any purpose?

    Edit - "Missing Braces and Parentheses" option seem to be what I need here. Why compiler flag doesn't do what it's supposed to do is maybe a bug in compiler or maybe I just don't understand how modern stuff works.

    :)
     
  4. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #4
    I add an equality test to make it even more explicit:
    Code:
    if ( (retImage = [imgDatabase imageWithAddress:imgAddress returnCode:NULL]) != NULL )  { blah... }
     
  5. jiminaus, Oct 22, 2011
    Last edited: Oct 22, 2011

    jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    This is a gcc flag. Is it also clang flag? There's no mention of it in the Clang Compiler User's Manual?
     
  6. idelovski, Oct 23, 2011
    Last edited: Oct 23, 2011

    idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #6
    Thanks for the link. It seems like there really is no support for that flag. I should see how is Xcode then passing this "Missing Braces and Parentheses" option to it.

    And PS, I see now that my first post is somewhat coarse so I want to add how I was one of those people who used Xcode in multiple windows setting. That and the fact that I was contemplating MacBook Air, but now I have no idea how could I fit everything on its screen when it's not at home/in the office on external monitor.
     

Share This Page