exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / stdnoreturn.in.h
blobc1161151a504288755e18d22416ee52cbb3febf3
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."
23 #endif
25 #ifndef noreturn
27 /* ISO C11 <stdnoreturn.h> for platforms that lack it.
29 References:
30 ISO C11 (latest free draft
31 <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
32 section 7.23
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
42 to the invalid
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
48 to the invalid
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*/
58 #else
59 # define noreturn _Noreturn
60 #endif
62 /* Did he ever return?
63 No he never returned
64 And his fate is still unlearn'd ...
65 -- Steiner J, Hawes BL. M.T.A. (1949) */
67 #endif /* noreturn */