objective-c - 在 ObjC 代码上使用 LLVM 3.0 抑制属性定义警告

标签 objective-c xcode llvm compiler-warnings suppress-warnings

由于 Xcode 4.2 附带了 LLVM 3.0,我们终于能够使用自动合成。您可以通过将以下两个标志添加到 Apple LLVM compiler 3.0 - Language 部分的 Other C Flags 来打开它:

  • -Xclang
  • -fobjc-default-synthesize-properties

现在,如果您只想要属性合成的默认设置(我想我们已经使用了自动引用计数),您可以摆脱您的@synthesize 样板代码。

当我点击构建时,编译器警告我缺少 @synthesize 等语句,如下所示:

MyController.h:34:43: warning: property 'myProperty' requires method 'myProperty' to be defined - use @synthesize, @dynamic or provide a method implementation [3]
@property (strong, nonatomic) MyClass *myProperty;

我更喜欢无警告构建,所以问题是:我怎样才能抑制这种警告,因为显然它们不再有意义了。

最佳答案

你确定 -Xclang 被传递给了编译器吗

clang -x objective-c -Xclang -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o 

不显示任何警告而

clang -x objective-c -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o

顺便说一下,这是正确的吗,因为没有合成属性

这是我使用的 TestClass.m:

#import <Foundation/Foundation.h>

@interface TestClass : NSObject

@property (nonatomic, strong) NSObject * test;

@end

@implementation TestClass

@end

关于objective-c - 在 ObjC 代码上使用 LLVM 3.0 抑制属性定义警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7892159/

相关文章:

objective-c - 当我用 BOOL 填充数组时发出警告

ios - 如何调整物镜C中具有透明部分的图像的大小

xcode - OS X 捆绑标识符名称 : Best practice in this situation

iphone - 为什么重力比例在 box2d 中不起作用

c++ - VS2017 'M_PI' : undeclared identifier

ios - Xcode 警告 : . .. 是 GNU 扩展

c++ - LLVM InstVisitor - 没有虚拟功能?

objective-c - objective-c - 局部静态变量初始化线程安全吗?

iphone - 如何使用 CIFeatures 将图像放在眼睛和嘴巴上

ios - Paypal ios PaymentViewController 不工作?