1 /* A substitute for ISO C11 <stdnoreturn.h>.
3 Copyright 2012-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 /* Written by Paul Eggert. */
20 /* This file uses _Noreturn. */
21 #if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
27 /* ISO C11 <stdnoreturn.h> for platforms that lack it.
30 ISO C11 (latest free draft
31 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
34 <stdnoreturn.h> is obsolescent in C23, so new code should avoid it. */
36 /* The definition of _Noreturn is copied here. */
38 #if 1200 <= _MSC_VER || defined __CYGWIN__
39 /* On MSVC, standard include files contain declarations like
40 __declspec (noreturn) void abort (void);
41 "#define noreturn _Noreturn" would cause this declaration to be rewritten
43 __declspec (__declspec (noreturn)) void abort (void);
45 Similarly, on Cygwin, standard include files contain declarations like
46 void __cdecl abort (void) __attribute__ ((noreturn));
47 "#define noreturn _Noreturn" would cause this declaration to be rewritten
49 void __cdecl abort (void) __attribute__ ((__attribute__ ((__noreturn__))));
51 Instead, define noreturn to empty, so that such declarations are rewritten to
52 __declspec () void abort (void);
54 void __cdecl abort (void) __attribute__ (());
55 respectively. This gives up on noreturn's advice to the compiler but at
56 least it is valid code. */
57 # define noreturn /*empty*/
59 # define noreturn _Noreturn
62 /* Did he ever return?
64 And his fate is still unlearn'd ...
65 -- Steiner J, Hawes BL. M.T.A. (1949) */