warning: passing argument 3 of 'objc_setProperty' as signed due to prototype

我的未来我决定 提交于 2019-12-24 19:24:04

问题


The compiler complains about this, after I activated all kind of warnings:

I have an app delegate like this:

#import <UIKit/UIKit.h>

@class MyViewController;

@interface TestAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MyViewController *myViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MyViewController *myViewController;

@end

In the implementation file, I have the synthesize code:

@synthesize window;
@synthesize rootViewController;

At the end of the implementation file, the compiler complains:

At top level:
warning: passing argument 3 of 'objc_setProperty' as signed due to prototype
warning: passing argument 5 of 'objc_setProperty' with different width due to prototype
warning: passing argument 6 of 'objc_setProperty' with different width due to prototype
warning: passing argument 3 of 'objc_setProperty' as signed due to prototype
warning: passing argument 5 of 'objc_setProperty' with different width due to prototype
warning: passing argument 6 of 'objc_setProperty' with different width due to prototype

What does that mean? Must I worry about it?


回答1:


Yes -- that isn't right. Not at all. And you should worry about it.

When you have a warning like this at the top level, it generally means that there is something screwed up in your header files that is causing problems later.

So, the question is, what? Could be a #define somewhere. Could be a previous declaration of something, specifically a declaration of something in an attempt to fix an error that would be appropriately fixed by #importing the correct system provided header.

Add the full compilation command line that spewed those warnings (you can find it in Xcode).




回答2:


I'm pretty sure you need to file a bug with Apple on this. I presume (having seen this warning) objc_setProperty (a private function, afaict) is used in Apple's implementation of the @synthesize setter code generation. So... this hidden implementation needs to change so the warning is not produced when that warning flag is enabled (GCC_WARN_PROTOTYPE_CONVERSION). These (and other) conditions should have been verified on a larger codebase (consider C++ as well), with more warnings enabled.



来源:https://stackoverflow.com/questions/1372312/warning-passing-argument-3-of-objc-setproperty-as-signed-due-to-prototype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!