[PATCH] D35379: Add documentation for @available

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 13 13:47:15 PDT 2017


erik.pilkington added inline comments.


================
Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+    if (@available(macOS 10.12)) {
+      [var fancyNewMethod];
----------------
thakis wrote:
> erik.pilkington wrote:
> > Don't forget the '*', ie @available(macos 10.12, *)!
> Done, thanks. What does the `*` do, by the way? :-)
Its supposed to make explicit that if the platform isn't listed in the @available, the true branch is taken and diagnostics are emitted in the then stmt using the deployment target version. The idea is that if a new platform is introduced, it would use existing APIs and it would be unfortunate if it broke everything. 

Now that I think about it, this should probably be mentioned, as its probably the most counter-intuitive part of this feature. Maybe something like: "If the platform your running on isn't listed in the @available, then the the true branch of the if is taken and warnings are emitted against the current deployment target."? It might also be nice if you added another OS to this example, like `@available(macOS 10.12, iOS 10, *)`?


https://reviews.llvm.org/D35379





More information about the cfe-commits mailing list