ref: f0e5c5ccc8c56a2e35ad9736fe293b8c73f87015
parent: 9b4959cb75183a866002a21371b7d09c08398045
author: stag019 <[email protected]>
date: Tue Dec 30 23:11:06 EST 2014
Cross-compiler noreturn support.
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,7 @@
$Qenv PATH=/usr/local/mingw32/bin:/bin:/usr/bin:/usr/local/bin \
make CC=gcc CFLAGS="-I/usr/local/mingw32/include \
-D__progname=\\\"\\\" \
- -D_Noreturn='__attribute__((noreturn))' ${CFLAGS}"
+ ${CFLAGS}"
$Qmv rgbasm rgbasm.exe
$Qmv rgblink rgblink.exe
$Qmv rgbfix rgbfix.exe
--- a/include/extern/err.h
+++ b/include/extern/err.h
@@ -29,6 +29,7 @@
#else
#include <stdarg.h>
+#include "extern/stdnoreturn.h"
#define warn rgbds_warn
#define vwarn rgbds_vwarn
@@ -49,10 +50,10 @@
void warnx(const char *, ...);
void vwarnx(const char *, va_list);
-_Noreturn void err(int, const char *, ...);
-_Noreturn void verr(int, const char *, va_list);
-_Noreturn void errx(int, const char *, ...);
-_Noreturn void verrx(int, const char *, va_list);
+noreturn void err(int, const char *, ...);
+noreturn void verr(int, const char *, va_list);
+noreturn void errx(int, const char *, ...);
+noreturn void verrx(int, const char *, va_list);
#ifdef __cplusplus
}
--- /dev/null
+++ b/include/extern/stdnoreturn.h
@@ -1,0 +1,16 @@
+#if _MSC_VER >= 1310
+ // MS Visual Studio 2003/.NET Framework 1.1 or newer
+ #define noreturn _declspec( noreturn)
+#elif __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ >= 5))
+ // GCC 2.5 or newer
+ #define noreturn __attribute__ ((noreturn))
+#elif __cplusplus >= 201103L
+ // C++11 or newer
+ #define noreturn [[noreturn]]
+#elif __STDC_VERSION__ >= 201112L
+ // C11 or newer
+ #define noreturn _Noreturn
+#else
+ // unsupported, but no need to throw a fit
+ #define noreturn
+#endif
--- a/src/extern/err.c
+++ b/src/extern/err.c
@@ -47,13 +47,13 @@
putc('\n', stderr);
}
-_Noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
+noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
{
vwarn(fmt, ap);
exit(status);
}
-_Noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
+noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
{
vwarnx(fmt, ap);
exit(status);
@@ -75,7 +75,7 @@
va_end(ap);
}
-_Noreturn void rgbds_err(int status, const char *fmt, ...)
+noreturn void rgbds_err(int status, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -83,7 +83,7 @@
va_end(ap);
}
-_Noreturn void rgbds_errx(int status, const char *fmt, ...)
+noreturn void rgbds_errx(int status, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);