Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jan 2012 23:05:23 +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: r229437 - head/include
Message-ID:  <201201032305.q03N5NWH047347@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Tue Jan  3 23:05:23 2012
New Revision: 229437
URL: http://svn.freebsd.org/changeset/base/229437

Log:
  Simply disallow <stdnoreturn.h> to be used in combination with C++.
  
  There is no way one could possibly use this header file in combination
  with C++ code. The problem is that in C11 the `noreturn' macro expands
  to the `_Noreturn' function specifier, while in C++11 the `noreturn'
  keyword is an attribute.
  
  So in C11 you have to write:
  
  	noreturn void exit(int status);
  
  While in C++11 you have to write:
  
  	[[noreturn]] void exit(int status);
  
  It is impossible to #define noreturn for C++ in such a way that it
  allows both conventions.
  
  By intentionally breaking this header this way, we prevent people from
  using this header in their C++<11 sources.

Modified:
  head/include/stdnoreturn.h

Modified: head/include/stdnoreturn.h
==============================================================================
--- head/include/stdnoreturn.h	Tue Jan  3 22:52:29 2012	(r229436)
+++ head/include/stdnoreturn.h	Tue Jan  3 23:05:23 2012	(r229437)
@@ -26,11 +26,13 @@
  * $FreeBSD$
  */
 
+#ifdef __cplusplus
+#error "<stdnoreturn.h> cannot be used in combination with C++11."
+#endif
+
 #ifndef noreturn
 
-#if !defined(__cplusplus) || __cplusplus < 201103L
 #include <sys/cdefs.h>
 #define	noreturn		_Noreturn
-#endif
 
 #endif /* !noreturn */



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