_Noreturn.h 1.43 KB
Newer Older
Paul Eggert's avatar
Paul Eggert committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* A C macro for declaring that a function does not return.
   Copyright (C) 2011-2019 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */

Paul Eggert's avatar
Paul Eggert committed
17
#ifndef _Noreturn
Paul Eggert's avatar
Paul Eggert committed
18 19 20
# if (defined __cplusplus \
      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
          || (defined _MSC_VER && 1900 <= _MSC_VER)))
Paul Eggert's avatar
Paul Eggert committed
21
#  define _Noreturn [[noreturn]]
Paul Eggert's avatar
Paul Eggert committed
22 23 24
# elif ((!defined __cplusplus || defined __clang__)                     \
        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
Paul Eggert's avatar
Paul Eggert committed
25 26
   /* _Noreturn works as-is.  */
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
27
#  define _Noreturn __attribute__ ((__noreturn__))
Paul Eggert's avatar
Paul Eggert committed
28
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
29 30 31 32 33
#  define _Noreturn __declspec (noreturn)
# else
#  define _Noreturn
# endif
#endif