• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Turning off spurious C warning in XCode ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turning off spurious C warning in XCode ?


  • Subject: Re: Turning off spurious C warning in XCode ?
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Sun, 23 Nov 2003 14:02:24 +0100

Responding to myself, I would like first to thank all who tried to help. In order to have an easy test case, anyone can try the following: creat a new project "Cocoa application", and change the main.m as follows:
/********* main *******/
@interface test {
int x;
}
@end


@implementation test

-init {
    int x = 0;
    x *= 5;
    return self;
}
@end

int main(int argc, const char *argv[])
{
    int argc = 0;
    return NSApplicationMain(argc, argv);
}
/********* end of main *******/

You will get two warnings, at line "x *= 5" and "int argc = 0":
warning: local declaration of `x' hides instance variable
warning: declaration of `argc' shadows a parameter

Note that they are different. I tried several way to remove them (including -Wno-shadow, etc.), with no avail.

You can get rid of the second warning but putting additionnal braces around the body of the main function, like that:
int main(int argc, const char *argv[])
{{
int argc = 0;
return NSApplicationMain(argc, argv);
}}
but this doesn't work for the init function (which unfortunately is the case of interest for me !).


So if anyone has an idea to get rid of this warning, I'm interested. Thanks,

Le 22 nov. 03, ` 18:13, Thomas Lachand-Robert a icrit :

Is there any way to turn off the warning about local declaration of variables which hides global variables in XCode?
For a class that contains a member named "session", I do the following in some method:


id session = [self session];

and get this spurious warning, which doesn't make sense here.

There is a checkbox about "hidden local variables" in the build settings, but it doesn't work for this.
I think the gcc option is -Wshadow, but again I don't know how to turn it off in XCode.


Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Turning off spurious C warning in XCode ?
      • From: Troy Dawson <email@hidden>
References: 
 >Turning off spurious C warning in XCode ? (From: Thomas Lachand-Robert <email@hidden>)

  • Prev by Date: Re: Turning off spurious C warning in XCode ?
  • Next by Date: Re: Turning off spurious C warning in XCode ?
  • Previous by thread: Re: Turning off spurious C warning in XCode ?
  • Next by thread: Re: Turning off spurious C warning in XCode ?
  • Index(es):
    • Date
    • Thread