From 112f2106470d3459b7ab29042e0e5144906473a2 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 3 Jan 2012 23:05:23 +0000 Subject: [PATCH] Simply disallow 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. --- include/stdnoreturn.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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$ */ -#ifndef noreturn - -#if !defined(__cplusplus) || __cplusplus < 201103L -#include -#define noreturn _Noreturn +#ifdef __cplusplus +#error " cannot be used in combination with C++11." #endif +#ifndef noreturn + +#include +#define noreturn _Noreturn + #endif /* !noreturn */