[x265] [PATCH 1/3] Fix Wundef for _MSC_VER
Johannes Kauffmann
johanneskauffmann at hotmail.com
Thu Jun 8 22:11:41 UTC 2023
This is mainly noticable when building another application, which
includes x265.h, with -Wundef, as _MSC_VER, among others, doesn't have
to be defined.
Additionally, also fix all cases of -Wundef warning for _MSC_VER when
building x265 itself. Use #ifdef where it suffices instead of #defined()
for consistency.
---
source/common/bitstream.cpp | 2 +-
source/common/common.h | 4 ++--
source/common/cpu.cpp | 2 +-
source/common/cpu.h | 4 ++--
source/common/dct.cpp | 2 +-
source/common/ipfilter.cpp | 2 +-
source/common/mv.h | 2 +-
source/common/param.cpp | 4 ++--
source/common/picyuv.cpp | 2 +-
source/common/pixel.cpp | 2 +-
source/common/predict.cpp | 2 +-
source/common/ringmem.h | 2 +-
source/common/scaler.cpp | 2 +-
source/common/threadpool.cpp | 2 +-
source/common/version.cpp | 2 +-
source/dynamicHDR10/json11/json11.cpp | 2 +-
source/encoder/api.cpp | 2 +-
source/encoder/encoder.cpp | 4 ++--
source/encoder/motion.cpp | 2 +-
source/encoder/ratecontrol.cpp | 4 ++--
source/encoder/search.cpp | 2 +-
source/input/y4m.cpp | 2 +-
source/input/yuv.cpp | 2 +-
source/output/raw.cpp | 2 +-
source/test/testharness.h | 2 +-
source/x265.cpp | 2 +-
source/x265.h | 2 +-
source/x265cli.cpp | 2 +-
28 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/source/common/bitstream.cpp b/source/common/bitstream.cpp
index b844749f5..34030bb27 100644
--- a/source/common/bitstream.cpp
+++ b/source/common/bitstream.cpp
@@ -4,7 +4,7 @@
using namespace X265_NS;
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4244)
#endif
diff --git a/source/common/common.h b/source/common/common.h
index 37c19ae72..9285bc4d5 100644
--- a/source/common/common.h
+++ b/source/common/common.h
@@ -116,7 +116,7 @@ namespace X265_NS { extern int g_checkFailures; }
if (fp) { fprintf(fp, "%s:%d\n", __FILE__, __LINE__); fprintf(fp, __VA_ARGS__); fclose(fp); } \
g_checkFailures++; DEBUG_BREAK(); \
}
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // some checks have constant conditions
#endif
#else
@@ -241,7 +241,7 @@ typedef int16_t coeff_t; // transform coefficient
} \
}
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#define X265_LOG2F(x) (logf((float)(x)) * 1.44269504088896405f)
#define X265_LOG2(x) (log((double)(x)) * 1.4426950408889640513713538072172)
#else
diff --git a/source/common/cpu.cpp b/source/common/cpu.cpp
index ce428c929..e1532c5fb 100644
--- a/source/common/cpu.cpp
+++ b/source/common/cpu.cpp
@@ -126,7 +126,7 @@ void PFX(cpu_cpuid)(uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, ui
uint64_t PFX(cpu_xgetbv)(int xcr);
}
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4309) // truncation of constant value
#endif
diff --git a/source/common/cpu.h b/source/common/cpu.h
index 52a9e9cba..c9fcd1a0a 100644
--- a/source/common/cpu.h
+++ b/source/common/cpu.h
@@ -35,9 +35,9 @@
extern "C" void PFX(cpu_emms)(void);
extern "C" void PFX(safe_intel_cpu_indicator_init)(void);
-#if _MSC_VER && _WIN64
+#if defined(_MSC_VER) && _WIN64
#define x265_emms() PFX(cpu_emms)()
-#elif _MSC_VER
+#elif defined(_MSC_VER)
#include <mmintrin.h>
#define x265_emms() _mm_empty()
#elif __GNUC__
diff --git a/source/common/dct.cpp b/source/common/dct.cpp
index b102b6e31..1667863ca 100644
--- a/source/common/dct.cpp
+++ b/source/common/dct.cpp
@@ -34,7 +34,7 @@
using namespace X265_NS;
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, typical for templated functions
#endif
diff --git a/source/common/ipfilter.cpp b/source/common/ipfilter.cpp
index 64f659d5f..d4760c5b0 100644
--- a/source/common/ipfilter.cpp
+++ b/source/common/ipfilter.cpp
@@ -30,7 +30,7 @@
using namespace X265_NS;
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, typical for templated functions
#endif
diff --git a/source/common/mv.h b/source/common/mv.h
index 5a8872cdd..da1dc6606 100644
--- a/source/common/mv.h
+++ b/source/common/mv.h
@@ -30,7 +30,7 @@
namespace X265_NS {
// private x265 namespace
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4201) // non-standard extension used (nameless struct/union)
#endif
diff --git a/source/common/param.cpp b/source/common/param.cpp
index 1a4df4cdc..032ef3a28 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -30,7 +30,7 @@
#include "x265.h"
#include "svt.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX functions are just fine, thanks
#pragma warning(disable: 4706) // assignment within conditional
#pragma warning(disable: 4127) // conditional expression is constant
@@ -885,7 +885,7 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)
else if (value[0] == '=')
value++;
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif
#define OPT(STR) else if (!strcmp(name, STR))
diff --git a/source/common/picyuv.cpp b/source/common/picyuv.cpp
index 58426a613..5f4088121 100644
--- a/source/common/picyuv.cpp
+++ b/source/common/picyuv.cpp
@@ -574,7 +574,7 @@ void updateCRC(const pixel* plane, uint32_t& crcVal, uint32_t height, uint32_t w
crcVal = (((crcVal << 1) + bitVal) & 0xffff) ^ (crcMsb * 0x1021);
}
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif
// take CRC of second pictureData byte if bit depth is greater than 8-bits
diff --git a/source/common/pixel.cpp b/source/common/pixel.cpp
index 3cd074cfa..56cc24b72 100644
--- a/source/common/pixel.cpp
+++ b/source/common/pixel.cpp
@@ -736,7 +736,7 @@ uint64_t pixel_var(const pixel* pix, intptr_t i_stride)
return sum + ((uint64_t)sqr << 32);
}
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif
diff --git a/source/common/predict.cpp b/source/common/predict.cpp
index a32bd05f7..444bec113 100644
--- a/source/common/predict.cpp
+++ b/source/common/predict.cpp
@@ -31,7 +31,7 @@
using namespace X265_NS;
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif
diff --git a/source/common/ringmem.h b/source/common/ringmem.h
index b14f7bee9..bec7dba74 100644
--- a/source/common/ringmem.h
+++ b/source/common/ringmem.h
@@ -27,7 +27,7 @@
#include "common.h"
#include "threading.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#define snprintf _snprintf
#define strdup _strdup
#endif
diff --git a/source/common/scaler.cpp b/source/common/scaler.cpp
index 879654793..d0c509e04 100644
--- a/source/common/scaler.cpp
+++ b/source/common/scaler.cpp
@@ -23,7 +23,7 @@
#include "scaler.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4706) // assignment within conditional
#pragma warning(disable: 4244) // '=' : possible loss of data
#endif
diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
index 91e82a24e..8fcd75b62 100644
--- a/source/common/threadpool.cpp
+++ b/source/common/threadpool.cpp
@@ -67,7 +67,7 @@
#if HAVE_LIBNUMA
#include <numa.h>
#endif
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif
diff --git a/source/common/version.cpp b/source/common/version.cpp
index 16a546756..43c9daf8d 100644
--- a/source/common/version.cpp
+++ b/source/common/version.cpp
@@ -49,7 +49,7 @@
#ifdef __INTEL_COMPILER
#define COMPILEDBY "[ICC " XSTR(__INTEL_COMPILER) "]"
-#elif _MSC_VER
+#elif defined(_MSC_VER)
#define COMPILEDBY "[MSVC " XSTR(_MSC_VER) "]"
#endif
diff --git a/source/dynamicHDR10/json11/json11.cpp b/source/dynamicHDR10/json11/json11.cpp
index 762577735..e0fded87f 100644
--- a/source/dynamicHDR10/json11/json11.cpp
+++ b/source/dynamicHDR10/json11/json11.cpp
@@ -26,7 +26,7 @@
#include <cstdio>
#include <limits>
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4510) //const member cannot be default initialized
#pragma warning(disable: 4512) //assignment operator could not be generated
#pragma warning(disable: 4610) //const member cannot be default initialized
diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp
index 15b898a3c..18edb9a70 100644
--- a/source/encoder/api.cpp
+++ b/source/encoder/api.cpp
@@ -78,7 +78,7 @@ x265_encoder *x265_encoder_open(x265_param *p)
if (!p)
return NULL;
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, yes I know
#endif
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index c2dd6f4e8..977ae19e3 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -42,7 +42,7 @@
#include "x265.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX functions are just fine, thanks
#endif
@@ -3161,7 +3161,7 @@ void Encoder::finishFrameStats(Frame* curFrame, FrameEncoder *curEncoder, x265_f
}
}
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4800) // forcing int to bool
#pragma warning(disable: 4127) // conditional expression is constant
#endif
diff --git a/source/encoder/motion.cpp b/source/encoder/motion.cpp
index 2bb613ec0..0edbc46dc 100644
--- a/source/encoder/motion.cpp
+++ b/source/encoder/motion.cpp
@@ -28,7 +28,7 @@
#include "motion.h"
#include "x265.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant (macros use this construct)
#endif
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index 42eaa673a..5b772aae0 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -23,7 +23,7 @@
* For more information, contact us at license @ x265.com.
*****************************************************************************/
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, yes I know
#endif
@@ -3231,7 +3231,7 @@ int RateControl::writeRateControlFrameStats(Frame* curFrame, RateControlEntry* r
x265_log(m_param, X265_LOG_ERROR, "RatecontrolEnd: stats file write failure\n");
return 1;
}
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX function names are just fine, thank you
#endif
diff --git a/source/encoder/search.cpp b/source/encoder/search.cpp
index dab11fc79..a55402558 100644
--- a/source/encoder/search.cpp
+++ b/source/encoder/search.cpp
@@ -36,7 +36,7 @@
using namespace X265_NS;
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4800) // 'uint8_t' : forcing value to bool 'true' or 'false' (performance warning)
#pragma warning(disable: 4244) // '=' : conversion from 'int' to 'uint8_t', possible loss of data)
#pragma warning(disable: 4127) // conditional expression is constant
diff --git a/source/input/y4m.cpp b/source/input/y4m.cpp
index bb55b6417..9cd92422a 100644
--- a/source/input/y4m.cpp
+++ b/source/input/y4m.cpp
@@ -32,7 +32,7 @@
#if _WIN32
#include <io.h>
#include <fcntl.h>
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX setmode and fileno deprecated
#endif
#endif
diff --git a/source/input/yuv.cpp b/source/input/yuv.cpp
index 0856a7217..382050485 100644
--- a/source/input/yuv.cpp
+++ b/source/input/yuv.cpp
@@ -32,7 +32,7 @@
#if _WIN32
#include <io.h>
#include <fcntl.h>
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX setmode and fileno deprecated
#endif
#endif
diff --git a/source/output/raw.cpp b/source/output/raw.cpp
index 7894e22fc..17e82bdf9 100644
--- a/source/output/raw.cpp
+++ b/source/output/raw.cpp
@@ -25,7 +25,7 @@
#if _WIN32
#include <io.h>
#include <fcntl.h>
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
#pragma warning(disable: 4996) // POSIX setmode and fileno deprecated
#endif
#endif
diff --git a/source/test/testharness.h b/source/test/testharness.h
index c03d7c2f5..56d7b6efe 100644
--- a/source/test/testharness.h
+++ b/source/test/testharness.h
@@ -29,7 +29,7 @@
#include "common.h"
#include "primitives.h"
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
#endif
diff --git a/source/x265.cpp b/source/x265.cpp
index 31a627d87..a428cd29a 100644
--- a/source/x265.cpp
+++ b/source/x265.cpp
@@ -21,7 +21,7 @@
* For more information, contact us at license @ x265.com.
*****************************************************************************/
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, yes I know
#endif
diff --git a/source/x265.h b/source/x265.h
index 1561a7a3e..901f33ded 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -32,7 +32,7 @@
extern "C" {
#endif
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4201) // non-standard extension used (nameless struct/union)
#endif
diff --git a/source/x265cli.cpp b/source/x265cli.cpp
index cbb3be593..eef101fe9 100755
--- a/source/x265cli.cpp
+++ b/source/x265cli.cpp
@@ -21,7 +21,7 @@
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
-#if _MSC_VER
+#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant, yes I know
#endif
--
2.34.1
More information about the x265-devel
mailing list