1 /*        $NetBSD: stdnoreturn.in.h,v 1.6 2024/08/18 20:47:25 christos Exp $    */
2 
3 /* A substitute for ISO C11 <stdnoreturn.h>.
4 
5    Copyright 2012-2018 Free Software Foundation, Inc.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as published by
9    the Free Software Foundation; either version 2.1, or (at your option)
10    any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU Lesser General Public License for more details.
16 
17    You should have received a copy of the GNU Lesser General Public License
18    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
19 
20 /* Written by Paul Eggert.  */
21 
22 #ifndef noreturn
23 
24 /* ISO C11 <stdnoreturn.h> for platforms that lack it.
25 
26    References:
27    ISO C11 (latest free draft
28    <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
29    section 7.23 */
30 
31 /* The definition of _Noreturn is copied here.  */
32 
33 #if 1200 <= _MSC_VER || defined __CYGWIN__
34 /* On MSVC, standard include files contain declarations like
35      __declspec (noreturn) void abort (void);
36    "#define noreturn _Noreturn" would cause this declaration to be rewritten
37    to the invalid
38      __declspec (__declspec (noreturn)) void abort (void);
39 
40    Similarly, on Cygwin, standard include files contain declarations like
41      void __cdecl abort (void) __attribute__ ((noreturn));
42    "#define noreturn _Noreturn" would cause this declaration to be rewritten
43    to the invalid
44      void __cdecl abort (void) __attribute__ ((__attribute__ ((__noreturn__))));
45 
46    Instead, define noreturn to empty, so that such declarations are rewritten to
47      __declspec () void abort (void);
48    or
49      void __cdecl abort (void) __attribute__ (());
50    respectively.  This gives up on noreturn's advice to the compiler but at
51    least it is valid code.  */
52 # define noreturn /*empty*/
53 #else
54 # define noreturn _Noreturn
55 #endif
56 
57 /* Did he ever return?
58    No he never returned
59    And his fate is still unlearn'd ...
60      -- Steiner J, Hawes BL.  M.T.A. (1949)  */
61 
62 #endif /* noreturn */
63