Warning "Previous prototype for function"

I use shareKit for myself.

but there is a warning in FBConnectGlobal,

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

like this method, he warns: "There is no previous prototype for the FBCreateNonRetainingArray function"

+45
ios iphone ipad
Aug 16 2018-11-11T00:
source share
4 answers

To make clear that Eric Dhao answered above, did someone from facebook apparently not put a β€œstatic” in front of this BOOL?

In any case, changing from this

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

to that

 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.

+49
Sep 12 2018-11-11T00:
source share

According to c standard, prototype declaration as

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

solves the problem.

+62
Oct 14 '11 at 7:55
source share

UPDATE . Turning off alerts is not a good solution, check out @Derek Bredensteiner's answer.

In Xcode 4, go to project build settings. Find "prototype". There should be an option "Missing function prototypes"; disconnect it.

through here

+28
Aug 24 2018-11-11T00:
source share

Is this a global feature? Add β€œ static ” if it is used only in the current file.

Possible reasons are as follows:

no previous prototype for `foo '

This means that GCC discovered a global function definition without seeing a function prototype. If the function is used in more than one file, there must be a prototype in the header file. This prevents synchronization of functions and their use.

If the function is used only in this file, make it static to ensure that it will never be used outside this file and document its local function

+7
Feb 03 2018-12-12T00:
source share



All Articles