Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Aug 2017 09:35:17 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322965 - head/sys/sys
Message-ID:  <201708280935.v7S9ZH9a058878@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Mon Aug 28 09:35:17 2017
New Revision: 322965
URL: https://svnweb.freebsd.org/changeset/base/322965

Log:
  Make _Static_assert() work with GCC in older C++ standards.
  
  GCC only activates C11 keywords in C mode, not C++ mode. This means
  that when targeting an older C++ standard, we cannot fall back to using
  _Static_assert(). In this case, do define _Static_assert() as a macro
  that uses a typedef'ed array.
  
  Discussed in:	r322875 commit thread
  Reported by:	Mark MIllard
  MFC after:	1 month

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==============================================================================
--- head/sys/sys/cdefs.h	Mon Aug 28 07:50:54 2017	(r322964)
+++ head/sys/sys/cdefs.h	Mon Aug 28 09:35:17 2017	(r322965)
@@ -294,7 +294,7 @@
 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
     __has_extension(cxx_static_assert)
 #define	_Static_assert(x, y)	static_assert(x, y)
-#elif __GNUC_PREREQ__(4,6)
+#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 #elif defined(__COUNTER__)
 #define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708280935.v7S9ZH9a058878>