Add workarounds for compilers that lack the fallthrough attribute.
authorDavid Griffith <dave@661.org>
Tue, 20 Feb 2018 11:37:50 +0000 (03:37 -0800)
committerDavid Griffith <dave@661.org>
Tue, 20 Feb 2018 11:37:50 +0000 (03:37 -0800)
src/common/frotz.h
src/common/quetzal.c

index 5794e4b7f2bd26fdd81e8cd4846208bae41a8419..7103e53c04944a7ad12a6970c7034a5a3af5ed03 100644 (file)
@@ -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;
index c3995592bc327ba70fd309fc72d6528dbdcf315f..459fe3e98607f250908b05e23504d3b5f80ac45a 100644 (file)
@@ -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. */