PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 27, 2022

[FIXED] How to handle the Xcode warning "no previous prototype for function..."?

 April 27, 2022     objective-c, warnings, xcode     No comments   

Issue

This warning is popping up a bunch in some third party libraries.

Is there a way to handle it without modifying the code (e.g. ignore the warning)?

If I have to modify the code to fix it how do I do it?

Here's one of the code blocks that's causing a warning:

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

Solution

Usually with warnings like this you can just define a function prototype at the top of your file, for instance:

BOOL FBIsDeviceIPad();

But in C a method with nothing between the braces, i.e. () actually implies there are an arbitrary number of parameters. Instead the definition should become (void) to denote no parameters:

BOOL FBIsDeviceIPad(void);

...

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


Answered By - appmattus
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing