From: David Griffith Date: Tue, 20 Feb 2018 11:37:50 +0000 (-0800) Subject: Add workarounds for compilers that lack the fallthrough attribute. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=a73391327e9226caafed7b64c0896d7bb0bc4fdb;p=liskon_frotz.git Add workarounds for compilers that lack the fallthrough attribute. --- diff --git a/src/common/frotz.h b/src/common/frotz.h index 5794e4b..7103e53 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -46,6 +46,20 @@ typedef int bool; #define PATH_SEPARATOR '/' #endif + +#ifndef __has_c_attribute /* Optional */ +#define __has_c_attribute(x) 0 /* Compat with non-clang compilers */ +#endif + +#if __has_c_attribute(fallthrough) +#define FALLTHROUGH [[fallthrough]] +#elif __GNUC__ >= 7 +#define FALLTHROUGH __attribute__((fallthrough)) +#else +#define FALLTHROUGH +#endif + + /* typedef unsigned short zbyte; */ typedef unsigned char zbyte; typedef unsigned short zword; diff --git a/src/common/quetzal.c b/src/common/quetzal.c index c399559..459fe3e 100644 --- a/src/common/quetzal.c +++ b/src/common/quetzal.c @@ -377,7 +377,7 @@ zword restore_quetzal (FILE *svf, FILE *stf) break; } /* Fall right thru (to default) if already GOT_MEMORY */ - __attribute__((fallthrough)); + FALLTHROUGH; /* `UMem' uncompressed memory chunk; load it. */ case ID_UMem: if (!(progress & GOT_MEMORY)) /* Don't complain if two. */ @@ -396,7 +396,7 @@ zword restore_quetzal (FILE *svf, FILE *stf) /* Fall into default action (skip chunk) on errors. */ } /* Fall thru (to default) if already GOT_MEMORY */ - __attribute__((fallthrough)); + FALLTHROUGH; /* Unrecognised chunk type; skip it. */ default: (void) fseek (svf, currlen, SEEK_CUR); /* Skip chunk. */