How to suppress “Availability does not match previous declaration” warning

断了今生、忘了曾经 提交于 2019-12-12 03:00:10

问题


I have to use some private functions, like:

SCDynamicStoreRef
SCDynamicStoreCreate            (
                    CFAllocatorRef          allocator,
                    CFStringRef         name,
                    SCDynamicStoreCallBack      callout,
                    SCDynamicStoreContext       *context
                    )               __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA);

By default they are not allowed for iphone, so I've changed declaration of them in my .m file. But now it shows "Availability does not match previous declaration" warning. How to suppress this warning?


回答1:


With the usual disclaimer that using private APIs might cause your app to be rejected: You can suppress the warning with

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wavailability"
…
#pragma clang diagnostic pop

It might also cause crashes or other failures if that function is present in the iOS frameworks, but with different parameters.



来源:https://stackoverflow.com/questions/23127996/how-to-suppress-availability-does-not-match-previous-declaration-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!