From 148772a841cae6f32db16d890e788b92a763bb3f Mon Sep 17 00:00:00 2001
From: Chris Lattner This document describes the language extensions provided by Clang. In
-addition to the langauge extensions listed here, Clang aims to support a broad
+addition to the language extensions listed here, Clang aims to support a broad
range of GCC extensions. Please see the GCC manual for
more information on these extensions. Language extensions can be very useful, but only if you know you can depend
+on them. In order to allow fine-grain features checks, we support two builtin
+function-like macros. This allows you to directly test for a feature in your
+code without having to resort to something like autoconf or fragile "compiler
+version checks". This function-like macro takes a single identifier argument that is the name
+of a builtin function. It evaluates to 1 if the builtin is supported or 0 if
+not. It can be used like this: This function-like macro takes a single identifier argument that is the name
+of a feature. It evaluates to 1 if the feature is supported or 0 if not. It
+can be used like this: The feature tag is described along with the language feature below.
Feature Checking Macros
+
+
+__has_builtin
+
+
+
+
+
+
+
+
+#ifndef __has_builtin // Optional of course.
+ #define __has_builtin(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_builtin(__builtin_trap)
+ __builtin_trap();
+#else
+ abort();
+#endif
+...
+
+__has_feature
+
+
+
+
+
+
+#ifndef __has_feature // Optional of course.
+ #define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_feature(attribute_overloadable) || \
+ __has_feature(blocks)
+...
+#endif
+...
+
+Builtin Macros
@@ -64,6 +126,8 @@ more information on these extensions.
Query for this feature with __has_feature(attribute_ext_vector_type).
+Query for this feature with __has_feature(blocks).
+Query for this feature with __has_feature(attribute_overloadable).
+ +void foo() __attribute__((analyzer_noreturn)); - ++ +
Query for this feature with __has_feature(attribute_analyzer_noreturn).
+