On Wed, 17 Apr 2019 10:01:13 +0000 Stefan Csomor wrote:
SC> from
https://developer.apple.com/library/archive/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html#//apple_ref/doc/uid/TP40001051-CH1-SW2
SC>
SC> "
SC> To guard the use of new APIs, use an if statement combined with @available, a new Objective-C expression that checks the system version. For example:
SC>
SC> if (@available(macOS 10.13, iOS 11, *)) {
SC> // The compiler will not warn about uses of APIs from macOS 10.13
SC> // or iOS 11 here
SC> }
SC> C or C++ code can use __builtin_available, a new builtin whose semantics are equivalent to @available.
SC> The -Wunguarded-availability flag is off by default to prevent unexpected warnings in existing projects. -Wunguarded-availability-new, a less strict version of the compiler flag that warns about unguarded uses of APIs only when they were introduced in macOS 10.13 or later, iOS 11 or later, tvOS 11 or later, or watchOS 4 or later. The -Wunguarded-availability-new flag is on by default. (7184689)
SC> "
SC>
SC> So we could somehow have a macro that is different when used in xcode9+ (for 10.14 SDK xcode 10 would be used anyway) and uses __builtin_available, the latter is used like so
SC> if (__builtin_available(iOS 11, macOS 10.13, *))
SC> {
SC> CFNewAPIOniOS11();
SC> }
SC>
SC> so we chould have a macro that both uses our own CheckVersion and __builtin_available
Thanks, I hadn't realized they also had a builtin for this and it indeed
makes things simpler and more understandable, so I've created
https://github.com/wxWidgets/wxWidgets/pull/1299
based on your idea (as you already know because I've requested your review
there, but I'm also posting it here in case anybody else might want to look
there and comment).
SC> BTW, is there some place where (modern) Objective-C syntax is concisely
SC> summarized? You usually can find things once you know what you're looking
SC> for, but my problem is that I almost never do and having some sort of an
SC> overview/summary would be very helpful.
SC>
SC> something like this :
https://www.raywenderlich.com/3028-objective-c-cheat-sheet-and-quick-reference ?
Thanks, but this is a bit too basic... I guess there is no substitute to
actually reading Apple docs, so I'll try to find time to do this.
Regards,
VZ