diff --git a/include/mgba-util/common.h b/include/mgba-util/common.h index 04018faf4..52a040198 100644 --- a/include/mgba-util/common.h +++ b/include/mgba-util/common.h @@ -265,6 +265,7 @@ typedef intptr_t ssize_t; #define ATTRIBUTE_UNUSED #define ATTRIBUTE_FORMAT(X, Y, Z) #define ATTRIBUTE_NOINLINE +#define ATTRIBUTE_NONSTRING // Adapted from https://stackoverflow.com/a/2390626 #define _CONSTRUCTOR(FN, PRE) \ static void FN(void); \ @@ -279,6 +280,11 @@ typedef intptr_t ssize_t; #define ATTRIBUTE_UNUSED __attribute__((unused)) #define ATTRIBUTE_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) #define ATTRIBUTE_NOINLINE __attribute__((noinline)) +#if defined(__llvm__) || (__GNUC__ < 8) +#define ATTRIBUTE_NONSTRING +#else +#define ATTRIBUTE_NONSTRING __attribute__((nonstring)) +#endif #define CONSTRUCTOR(FN) static __attribute__((constructor)) void FN(void) #endif diff --git a/include/mgba/gba/interface.h b/include/mgba/gba/interface.h index 298292dd3..1fc9b06bb 100644 --- a/include/mgba/gba/interface.h +++ b/include/mgba/gba/interface.h @@ -87,7 +87,7 @@ enum { }; struct GBACartridgeOverride { - char id[4]; + char id[4] ATTRIBUTE_NONSTRING; enum GBASavedataType savetype; int hardware; uint32_t idleLoop; diff --git a/src/gb/test/gbx.c b/src/gb/test/gbx.c index b15502e37..fe802e410 100644 --- a/src/gb/test/gbx.c +++ b/src/gb/test/gbx.c @@ -16,7 +16,7 @@ struct GBXParams { uint32_t major; uint32_t minor; - char fourcc[4]; + char fourcc[4] ATTRIBUTE_NONSTRING; bool battery; bool rumble; bool timer;