“没有先前的原型函数”警告

时间:2022-04-09 18:49:32

i use shareKit to myself program .

我用shareKit为自己编程。

but in the FBConnectGlobal, there are some warning,

但是在FBConnectGlobal中,有一些警告,

NSMutableArray* FBCreateNonRetainingArray() {
  CFArrayCallBacks callbacks = kCFTypeArrayCallBacks;
  callbacks.retain = RetainNoOp;
  callbacks.release = ReleaseNoOp;
  return (NSMutableArray*)CFArrayCreateMutable(nil, 0, &callbacks);
}

like this method, it warning:"No previous prototype for function FBCreateNonRetainingArray"

像这个方法一样,它警告说:“以前没有FBCreateNonRetainingArray函数原型”

4 个解决方案

#1


49  

To clarify Eric Dchao's answer above, someone at facebook apparently didn't put a "static" in front of that BOOL?

为了澄清Eric Dchao的回答,facebook上的一些人显然没有在BOOL面前加一个“静态”?

Anyways, changing from this

无论如何,从这个变化

BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
  }
#endif
  return NO;
}

to this

这个

static BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
  }
#endif
  return NO;
}

fixed it for me.

给我固定它。

#2


62  

According to c standard, declaring the prototype as

根据c标准,将原型声明为

NSMutableArray* FBCreateNonRetainingArray(void);
//      --------------->                  ^^^^   
// Yes, with the void as the parameter

solves the issue.

解决了这个问题。

#3


28  

UPDATE: Disable warnings is not a good solution, check @Derek Bredensteiner's answer.

更新:禁用警告不是一个好的解决方案,检查@Derek Bredensteiner的答案。

In Xcode 4, go to your project's Build Settings. Search for "prototype". There should be an option called "Missing Function Prototypes"; disable it.

在Xcode 4中,转到项目的构建设置。搜索“原型”。应该有一个叫做“丢失函数原型”的选项;禁用它。

via here

通过这里

#4


7  

Is it a global function? Add "static" if it is only used in the current file.

它是一个全局函数吗?如果只在当前文件中使用,则添加“静态”。

The possible reason is as below:

可能的原因如下:

no previous prototype for `foo'

没有之前的“foo”原型

This means that GCC found a global function definition without seeing a prototype for the function. 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

这意味着GCC在没有看到函数原型的情况下找到了全局函数定义。如果一个函数在多个文件中使用,那么在头文件中应该有一个原型。这使函数和它们的使用不同步。

If the function is only used in this file, make it static to guarantee that it'll never be used outside this file and document that it's a local function

如果这个函数只在这个文件中使用,那么将它设置为静态,以保证它永远不会在这个文件之外使用,并记录它是一个本地函数

#1


49  

To clarify Eric Dchao's answer above, someone at facebook apparently didn't put a "static" in front of that BOOL?

为了澄清Eric Dchao的回答,facebook上的一些人显然没有在BOOL面前加一个“静态”?

Anyways, changing from this

无论如何,从这个变化

BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
  }
#endif
  return NO;
}

to this

这个

static BOOL FBIsDeviceIPad() {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
  }
#endif
  return NO;
}

fixed it for me.

给我固定它。

#2


62  

According to c standard, declaring the prototype as

根据c标准,将原型声明为

NSMutableArray* FBCreateNonRetainingArray(void);
//      --------------->                  ^^^^   
// Yes, with the void as the parameter

solves the issue.

解决了这个问题。

#3


28  

UPDATE: Disable warnings is not a good solution, check @Derek Bredensteiner's answer.

更新:禁用警告不是一个好的解决方案,检查@Derek Bredensteiner的答案。

In Xcode 4, go to your project's Build Settings. Search for "prototype". There should be an option called "Missing Function Prototypes"; disable it.

在Xcode 4中,转到项目的构建设置。搜索“原型”。应该有一个叫做“丢失函数原型”的选项;禁用它。

via here

通过这里

#4


7  

Is it a global function? Add "static" if it is only used in the current file.

它是一个全局函数吗?如果只在当前文件中使用,则添加“静态”。

The possible reason is as below:

可能的原因如下:

no previous prototype for `foo'

没有之前的“foo”原型

This means that GCC found a global function definition without seeing a prototype for the function. 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

这意味着GCC在没有看到函数原型的情况下找到了全局函数定义。如果一个函数在多个文件中使用,那么在头文件中应该有一个原型。这使函数和它们的使用不同步。

If the function is only used in this file, make it static to guarantee that it'll never be used outside this file and document that it's a local function

如果这个函数只在这个文件中使用,那么将它设置为静态,以保证它永远不会在这个文件之外使用,并记录它是一个本地函数