"This function declaration is not a prototype" warning in Xcode 9
The block declaration with empty parenthesis:
void (^)()
has the same semantics as a function pointer with empty parenthesis:
void (*)()
It does not mean that there are no arguments. It means the arguments are not specified, therefore it opens the way to bugs since you can call it in the following ways:
void (^block)() = ...
block();
block(10);
block(@"myString");
When declaring blocks with no parameters, always use:
void (^)(void)
Apple was not doing that correctly everywhere and they are not probably fixing that for old APIs for compatibility reasons. You will have to keep that warning there until you move to the newer API.
You can also turn off that warning (-Wstrict-prototypes
):
or using #pragma
(thanks @davidisdk):
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
- (void)application:(UIApplication *)application
handleActionWithIdentifier:(NSString *)identifier
forRemoteNotification:(NSDictionary *)userInfo
withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)())completionHandler {
}
#pragma clang diagnostic pop
See the LLVM discussion here or the bug on openradar.
Note that's there was no change in the internal working of the APIs, all code will still work. We will only know that the API is not as good as it should be.