【发布时间】:2020-12-01 07:51:44
【问题描述】:
通过咨询document,我知道您可以通过以下方式为C函数添加注释
#pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = function)
void function(); // The function now has the annotate("custom") attribute
void function1();
void function2();
#pragma clang attribute pop
但是在Objective-C方法中会报错
错误信息:
@implementation STAppDelegate
#pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = objc_method)
- (void)a {
NSLog(@"%s", __func__);
}
- (void)b {
NSLog(@"%s", __func__);
}
- (void)c {
NSLog(@"%s", __func__);
}
#pragma clang attribute pop
@end
【问题讨论】:
-
图片告诉我问题是你需要在 Objective-C 中将字符串写成
@"string"而不是"string"。与注释无关,但与@修饰符无关。 -
或使用
fprintf(stderr,"string");而不是NSLog() -
对不起,我上传了错误的图片,现在我上传了正确的图片,我还是报错
-
你:......上传了错误的图片......我:只是惩罚使用图片而不是代码。无论如何,它应该工作。检查您的编译器标志 - 必须是铿锵声。此外,push 和 pop 需要平衡。使用粘贴到我的代码中的确切推送和弹出行,这方面工作正常。
-
我知道问题的原因了,我用的Xcode版本比较低,clang版本比较低,不支持
标签: c++ ios objective-c clang llvm