stdnoreturn.in.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* A substitute for ISO C11 <stdnoreturn.h>.
  2. Copyright 2012-2016 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 <http://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
  22. /* Standard include files on this platform contain declarations like
  23. "__declspec (noreturn) void abort (void);". "#define noreturn
  24. _Noreturn" would cause this declaration to be rewritten to the
  25. invalid "__declspec (__declspec (noreturn)) void abort (void);".
  26. Instead, define noreturn to empty, so that such declarations are
  27. rewritten to "__declspec () void abort (void);", which is
  28. equivalent to "void abort (void);"; this gives up on noreturn's
  29. advice to the compiler but at least it is valid code. */
  30. # define noreturn /*empty*/
  31. #else
  32. # define noreturn _Noreturn
  33. #endif
  34. /* Did he ever return?
  35. No he never returned
  36. And his fate is still unlearn'd ...
  37. -- Steiner J, Hawes BL. M.T.A. (1949) */
  38. #endif /* noreturn */