diff --git a/c/cvalues.h b/c/cvalues.h index 42b822a..42caf51 100644 --- a/c/cvalues.h +++ b/c/cvalues.h @@ -1327,7 +1327,8 @@ int numeric_compare(value_t a, value_t b, int eq, int eqnans, char *fname) return 1; } -static void DivideByZeroError() __attribute__((__noreturn__)); +STATIC_NORETURN(void, DivideByZeroError()); + static void DivideByZeroError(void) { lerror(DivideError, "/: division by zero"); diff --git a/c/dtypes.h b/c/dtypes.h index 552c36c..8db7a4c 100644 --- a/c/dtypes.h +++ b/c/dtypes.h @@ -16,6 +16,22 @@ #undef BITS32 // TODO #define BITS64 // TODO +#ifdef __GNUC__ +#define EXTERN_NORETURN(ret, args) extern ret args __attribute__((__noreturn__)) +#define STATIC_NORETURN(ret, args) static ret args __attribute__((__noreturn__)) +#endif + +#ifdef _MSC_VER +#define EXTERN_NORETURN(ret, args) __declspec(noreturn) extern ret args +#define STATIC_NORETURN(ret, args) __declspec(noreturn) static ret args +#endif + +#ifdef __WATCOMC__ +#pragma aux noreturn aborts; +#define EXTERN_NORETURN(ret, args) extern ret __pragma("noreturn") args +#define STATIC_NORETURN(ret, args) static ret __pragma("noreturn") args +#endif + #define LLT_ALLOC(n) malloc(n) #define LLT_REALLOC(p, n) realloc((p), (n)) #define LLT_FREE(x) free(x) diff --git a/c/flisp.h b/c/flisp.h index 007c13f..dc87e8c 100644 --- a/c/flisp.h +++ b/c/flisp.h @@ -190,15 +190,13 @@ extern value_t fl_lasterror; #define FL_CATCH_EXTERN \ else for (l__ca = 1; l__ca; l__ca = 0, fl_restorestate(&_ctx)) -void lerrorf(value_t e, char *format, ...) __attribute__((__noreturn__)); -void lerror(value_t e, const char *msg) __attribute__((__noreturn__)); +EXTERN_NORETURN(void, lerrorf(value_t e, char *format, ...)); +EXTERN_NORETURN(void, lerror(value_t e, const char *msg)); void fl_savestate(struct fl_exception_context *_ctx); void fl_restorestate(struct fl_exception_context *_ctx); -void fl_raise(value_t e) __attribute__((__noreturn__)); -void type_error(char *fname, char *expected, value_t got) -__attribute__((__noreturn__)); -void bounds_error(char *fname, value_t arr, value_t ind) -__attribute__((__noreturn__)); +EXTERN_NORETURN(void, fl_raise(value_t e)); +EXTERN_NORETURN(void, type_error(char *fname, char *expected, value_t got)); +EXTERN_NORETURN(void, bounds_error(char *fname, value_t arr, value_t ind)); extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError; extern value_t UnboundError;