Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 740 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"This function declaration is not a prototype" warning in Xcode 9

#1
When using Xcode 9, there are some compiler warnings saying `This function declaration is not a prototype`. It suggests to add `void` to the method body, which will resolve it. The issue I am having is that those warnings are also thrown for system-API's like `UIApplication` delegate-methods:

- (void)application:(UIApplication *)application
handleActionWithIdentifier:(NSString *)identifier
forRemoteNotification:(NSDictionary *)userInfo
withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)())completionHandler

This could be resolved by the following:

- (void)application:(UIApplication *)application
handleActionWithIdentifier:(NSString *)identifier
forRemoteNotification:(NSDictionary *)userInfo
withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)(void))completionHandler


Now I am wondering if the delegate methods will still work on the long-term or Apple will insert the `void` in later iOS 11 Beta versions. I am curious because if I include the `void` body, Xcode will complain about mismatching method-selectors (which makes sense). Did someone experience the same issue so far?
Reply

#2
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`):
[![enter image description here][1]][1]

or using `#pragma` (thanks [@davidisdk][2]):

#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][3] or the bug on [openradar][4].

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.


[1]:

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through