diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index d13e462042..fc35409dc2 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -968,10 +968,12 @@ CCMD (dump3df) fixed_t height=ffloors[i]->top.plane->ZatPoint(CenterSpot(sector)); fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(CenterSpot(sector)); + IGNORE_FORMAT_PRE Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", i, height / 65536., ffloors[i]->top.model->sectornum, bheight / 65536., ffloors[i]->bottom.model->sectornum, ffloors[i]->flags, ffloors[i]->alpha, (ffloors[i]->flags&FF_EXISTS)? "Exists":"", (ffloors[i]->flags&FF_DYNAMIC)? "Dynamic":""); + IGNORE_FORMAT_POST } } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2929eb32a0..2ea64f26ea 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -7496,22 +7496,9 @@ scriptwait: break; case PCD_PRINTBINARY: -#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6)))) || defined(__clang__) -#define HAS_DIAGNOSTIC_PRAGMA -#endif -#ifdef HAS_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic push -#ifdef __clang__ -#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" -#else -#pragma GCC diagnostic ignored "-Wformat=" -#endif -#pragma GCC diagnostic ignored "-Wformat-extra-args" -#endif + IGNORE_FORMAT_PRE work.AppendFormat ("%B", STACK(1)); -#ifdef HAS_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic pop -#endif + IGNORE_FORMAT_POST --sp; break; diff --git a/src/zstring.h b/src/zstring.h index 1736f34212..fe7ee72cfb 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -47,6 +47,24 @@ #define PRINTFISH(x) #endif +#ifdef __clang__ +#define IGNORE_FORMAT_PRE \ + _Pragma("GCC diagnostic push" \ + _Pragma("GCC diagnostic ignored \"-Wformat-invalid-specifier\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") +#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))) +#define IGNORE_FORMAT_PRE \ + _Pragma("GCC diagnostic push" \ + _Pragma("GCC diagnostic ignored \"-Wformat=\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") +#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") +#else +#define IGNORE_FORMAT_PRE +#define IGNORE_FORMAT_POST +#endif + + struct FStringData { unsigned int Len; // Length of string, excluding terminating null