Can't use gcc -Wundeclared-selector in a mixed Obj-C and C project.
| Originator: | DavidPhillipOster | ||
| Number: | rdar://7295341 | Date Originated: | 10/12/09 |
| Status: | Closed | Resolved: | Works As Intended |
| Product: | Xcode | Product Version: | 3.1.3 |
| Classification: | Other Bug | Reproducible: | Always |
12-Oct-2009 10:49 AM David Phillip Oster: Summary: Can't use gcc -Wundeclared-selector in a mixed Obj-C and C project. Steps to Reproduce: Add -Wall -Werror -Wundeclared-selector to the WARNING_CFLAGS build setting of Xcode. Attempt to compile an Xcode project that contains both .c and .m files. Expected Results: gcc should complain about undeclared selectors, if they are present in the objective-c sources. Since undeclared selectors can never occur in .c files, the warning about Obj-C only is extraneous. Actual Results: gcc complains that -Wundeclared-selector is inapplicable to .c files. Since we've set "treat warnings as errors" this stops the compilation. Regression: Didn't try. Notes: * It should be possible to use -Wundeclared-selector in a mixed C and Obj-C program. * It should not be necessary to specify -Wundeclared-selector is you've already specified -Wall "-Wall" should MEAN all. ----- Apple closed this as: Works as Intended, saying: "What you should do here is to enable the GCC_WARN_UNDECLARED_SELECTOR build setting (which is defined to pass -Wundeclared-selector only for C/ObjC) rather than putting -Wundeclared-selector in WARNING_CFLAGS."
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Xcode has an "undeclared selectors" checkbox. That should apply just to .m and .mm files.
Thanks to Uli Kusterer for pointing that out. I'd missed it.
That checkbox is new in Xcode 3.2 I think, and is a good workaround for this one case, but not a solution in the general case. See rdar://5295989