ios - Xcode 警告 : No Previous Prototype for Function

标签 ios objective-c

我在以下代码中收到警告“函数‘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

[Source]

请不要忽视警告,除非您知道它们是什么,它们可能构成比您意识到的更大的威胁。


与您的问题略有关系,但您可能会发现这更容易本地化您的字符串。这是我使用的解决方案:

#define local(s) NSLocalizedString(s, s)

然后调用 local(@"myStringKey");

关于ios - Xcode 警告 : No Previous Prototype for Function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7863313/

相关文章:

ios - 如何在 Swift 4 JSON 解码中包含枚举?

iphone - 具有单独 .xib 的两个目标(具有相同名称的图像资源)

ios - 从关系开始查询

ios - 不同iOS版本中Int的最大值是多少?

ios - 当我们在 iOS swift 中单击文本字段时,是否可以显示操作表并隐藏键盘?

c# - 如何在c# monotuch中打印多个页面的UITableview内容数据

objective-c - 如何在 Objective-C 中表示无穷大?

objective-c - 如何删除缓存目录中的内容?

objective-c - iOS:在屏幕上捕获 CAEmitterLayer 粒子

objective-c - 阻止父 View 在 subview 对其进行操作后接收触摸事件