stdnoreturn.in.h 2.1 KB

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