aboutsummaryrefslogtreecommitdiffstats
path: root/include/stdnoreturn.h
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-01-03 23:05:23 +0000
committerEd Schouten <ed@FreeBSD.org>2012-01-03 23:05:23 +0000
commit112f2106470d3459b7ab29042e0e5144906473a2 (patch)
tree1534560cc5c1a3a61752460a13a22495e7041255 /include/stdnoreturn.h
parentba804f54f94ebfce39ab29f5feb7c57ce0565bf0 (diff)
downloadsrc-112f2106470d3459b7ab29042e0e5144906473a2.tar.gz
src-112f2106470d3459b7ab29042e0e5144906473a2.zip
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.
Notes
Notes: svn path=/head/; revision=229437
Diffstat (limited to 'include/stdnoreturn.h')
-rw-r--r--include/stdnoreturn.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/stdnoreturn.h b/include/stdnoreturn.h
index f022730e8a49..218a3a0ad111 100644
--- a/include/stdnoreturn.h
+++ b/include/stdnoreturn.h
@@ -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 */