[Midnightbsd-cvs] src [9889] trunk/sys/sys/cdefs.h: add better handling of c extensions
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu May 24 13:48:33 EDT 2018
Revision: 9889
http://svnweb.midnightbsd.org/src/?rev=9889
Author: laffer1
Date: 2018-05-24 13:48:32 -0400 (Thu, 24 May 2018)
Log Message:
-----------
add better handling of c extensions
Modified Paths:
--------------
trunk/sys/sys/cdefs.h
Modified: trunk/sys/sys/cdefs.h
===================================================================
--- trunk/sys/sys/cdefs.h 2018-05-24 13:22:06 UTC (rev 9888)
+++ trunk/sys/sys/cdefs.h 2018-05-24 17:48:32 UTC (rev 9889)
@@ -278,7 +278,8 @@
#define _Alignof(x) __alignof(x)
#endif
-#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
+#if !defined(__cplusplus) && !__has_extension(c_atomic) && \
+ !__has_extension(cxx_atomic)
/*
* No native support for _Atomic(). Place object in structure to prevent
* most forms of direct non-atomic access.
@@ -336,6 +337,21 @@
__builtin_types_compatible_p(__typeof(expr), t), yes, no)
#endif
+/*
+ * C99 Static array indices in function parameter declarations. Syntax such as:
+ * void bar(int myArray[static 10]);
+ * is allowed in C99 but not in C++. Define __min_size appropriately so
+ * headers using it can be compiled in either language. Use like this:
+ * void bar(int myArray[__min_size(10)]);
+ */
+#if !defined(__cplusplus) && \
+ (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
+ (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
+#define __min_size(x) static (x)
+#else
+#define __min_size(x) (x)
+#endif
+
#if __GNUC_PREREQ__(2, 96)
#define __malloc_like __attribute__((__malloc__))
#define __pure __attribute__((__pure__))
More information about the Midnightbsd-cvs
mailing list