How to handle the Xcode warning “no previous prototype for function…”?

后端 未结 3 798
予麋鹿
予麋鹿 2021-02-02 06:21

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

3条回答
  •  离开以前
    2021-02-02 07:19

    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;
    }
    

提交回复
热议问题