site_archiver@lists.apple.com Delivered-To: Cocoa-dev@lists.apple.com User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 On 10/23/18 5:36 PM, Saagar Jha wrote: Saagar Jha On 10/23/18 3:12 PM, Saagar Jha wrote: #import <AppKit/AppKit.h> int main() { NSPrintInfo *info; if (@available(macOS 10.9, *)) { info.orientation = NSPaperOrientationPortrait; } else { info.orientation = NSPortraitOrientation; } } I'm not sure what you mean by "cast through NSInteger", but if I say info.orientation = (NSInteger) NSPortraitOrientation; Saagar Jha I had some code like this pInfo.orientation = NSPaperOrientationPortrait; if (@available( macOS 10.9, * )) { pInfo.orientation = NSPaperOrientationPortrait; } else { pInfo.orientation = NSPortraitOrientation } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com On Oct 23, 2018, at 17:15, James Walker <jamesw@frameforge3d.com <mailto:jamesw@frameforge3d.com>> wrote: What build command are you using? I’m not seeing any warnings with this code, compiled with clang -x objective-c -framework AppKit -Wunguarded-availability -mmacosx-version-min=10.9 - : If you compile with a deployment version of 10.9, I don't know if it even bothers to look at the else clause. Try -mmacosx-version-min=10.8. Oops, that was a typo. I meant -mmacosx-version-min=10.8. Either way, @available is checked at runtime, so both cases must be compiled anyways. Regardless, if you really need a fix, you should be able to cast through NSInteger, instead of NSPrintingOperation, as a fallback. then there's an error, "assigning to NSPaperOrientation from incompatible type NSInteger (aka long)”. I’m not seeing that error at all, even with -Wall -Wextra. What flags are you using? Hmm, it appears to be because I'm using Objective-C++. When I put that line in a .m file, there was no error. On Oct 23, 2018, at 15:01, James Walker <jamesw@frameforge3d.com <mailto:jamesw@frameforge3d.com>> wrote: where pInfo is of type NSPrintInfo*. When compiling with -Wunguarded-availability, I got a warning saying that NSPaperOrientationPortrait is only available on macOS 10.9 and later. So I wanted to change it to: But then I get an error, "assigning to NSPaperOrientation from incompatible type NSPrintingOrientation". If I fix the error by adding a typecast to NSPaperOrientation, then I get a warning that NSPaperOrientation is only available on 10.9 and later. Is there any way out of this roundabout, other than using a later deployment target?