6

Is there a #pragma to override a compile time warning, e.g.:

warning: 'ADBannerContentSizeIdentifier480x32' is deprecated (declared at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/iAd.framework/Headers/ADBannerView.h:111)

I have to keep compatibility for pre-4.2 iOS devices by:

NSString *iAdSize = (osVersion >= 4.2) ? ADBannerContentSizeIdentifierPortrait : ADBannerContentSizeIdentifier480x32;

Thanks

3 Answers 3

8

Yes there is

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wno-deprecated-declarations"
//deprecated function
#pragma clang diagnostic pop

If you ever wonder what the proper syntax is for a certain error just find it in Xcode then look at the quick help

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I had to use #pragma clang diagnostic ignored "-Wdeprecated-declarations" for it to work.
2

There's a build setting to toggle warning for deprecated functions.

Though the right way to do this would be check for OS version at runtime, and execute the deprecated method if necessary, or the new one otherwise.

2 Comments

I am looking for a switch to turn off one specific deprecated warning which I know what I am doing, but not turning off all. Thx.
In that case, check out my other answer to this question.
0

You can suppress a specific deprecated warning by creating a 'Deprecated.h' file, in which you declare the deprecated methods as good in a category.

1 Comment

this is a bad idea, you should instead just suppress the specific warning using the pragma syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.