我在以下代码中收到警告“函数‘LocStr’没有以前的原型(prototype)”:
NSString *LocStr(NSString *const key) {
return [[NSBundle mainBundle] localizedStringForKey:key value:nil table:nil];
}
所有代码都工作正常,将应用程序提交到 App Store 时出现此警告是否有问题?这个警告有问题吗?
我可以在 Build Settings -> Missing Function Prototypes -> NO 中禁用原型(prototype)警告。但我想确保此警告不会在将来导致崩溃和拒绝。
有人吗?
谢谢!
最佳答案
看看这个。您可能违反了这里的哪些可能性?
no previous prototype for `foo'
This means that GCC found a global function definition without seeing a prototype for the function.
o If a function is used in more than one file, there should be a prototype for it in a header file somewhere. This keeps functions and their uses from getting out of sync
o If the function is only used in this file, make it static to guarantee that it'll never be used outside this file document that it's a local function
请不要忽视警告,除非您知道它们是什么,它们可能构成比您意识到的更大的威胁。
与您的问题略有关系,但您可能会发现这更容易本地化您的字符串。这是我使用的解决方案:
#define local(s) NSLocalizedString(s, s)
然后调用 local(@"myStringKey");
关于ios - Xcode 警告 : No Previous Prototype for Function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7863313/