Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No previous prototype for function" warning

Tags:

ios

iphone

ipad

i use shareKit to myself program .

but in the FBConnectGlobal, there are some warning,

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"

like image 975
Wang Yanchao Avatar asked Aug 16 '11 09:08

Wang Yanchao


3 Answers

According to c standard, declaring the prototype as

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

solves the issue.

like image 139
daveswen Avatar answered Oct 14 '22 12:10

daveswen


To clarify Eric Dchao's answer above, someone at facebook apparently didn't put a "static" in front of that 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.

like image 20
Derek Bredensteiner Avatar answered Oct 14 '22 11:10

Derek Bredensteiner


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

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

via here

like image 28
fannheyward Avatar answered Oct 14 '22 12:10

fannheyward