From 5f5918301e86090a5f8c6520182ec1d267d03d9f Mon Sep 17 00:00:00 2001 From: Marco Eichelberg Date: Wed, 6 Mar 2024 08:38:40 +0100 Subject: [PATCH] Suppress MSVC warning in unit test. --- ofstd/include/dcmtk/ofstd/diag/unarymin.def | 4 ++++ ofstd/include/dcmtk/ofstd/ofdiag.h | 10 +++++++++- ofstd/tests/tlimits.cc | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 ofstd/include/dcmtk/ofstd/diag/unarymin.def diff --git a/ofstd/include/dcmtk/ofstd/diag/unarymin.def b/ofstd/include/dcmtk/ofstd/diag/unarymin.def new file mode 100644 index 0000000000..6b9b121153 --- /dev/null +++ b/ofstd/include/dcmtk/ofstd/diag/unarymin.def @@ -0,0 +1,4 @@ +// Clang and GCC don't seem to have such a warning +#ifdef _MSC_VER +#pragma warning(disable: 4146) +#endif diff --git a/ofstd/include/dcmtk/ofstd/ofdiag.h b/ofstd/include/dcmtk/ofstd/ofdiag.h index 460929acf2..0590a3857f 100644 --- a/ofstd/include/dcmtk/ofstd/ofdiag.h +++ b/ofstd/include/dcmtk/ofstd/ofdiag.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2016-2023, OFFIS e.V. + * Copyright (C) 2016-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -239,6 +239,13 @@ */ #define DCMTK_DIAGNOSTIC_IGNORE_ARRAY_BOUNDS +/*! @brief A macro to disable warnings about the use of the unary minus + * operator with an unsigned integer type + * @note The macro may only be used in conjunction with #include! + * @see DCMTK_DIAGNOSTIC_PUSH for an example. + */ +#define DCMTK_DIAGNOSTIC_IGNORE_UNSIGNED_UNARY_MINUS + #else // DOXYGEN #define DCMTK_DIAGNOSTIC_PUSH "dcmtk/ofstd/diag/push.def" @@ -266,6 +273,7 @@ #define DCMTK_DIAGNOSTIC_IGNORE_RESTRICT "dcmtk/ofstd/diag/restrict.def" #define DCMTK_DIAGNOSTIC_IGNORE_USE_AFTER_FREE "dcmtk/ofstd/diag/useafree.def" #define DCMTK_DIAGNOSTIC_IGNORE_ARRAY_BOUNDS "dcmtk/ofstd/diag/arrybnds.def" +#define DCMTK_DIAGNOSTIC_IGNORE_UNSIGNED_UNARY_MINUS "dcmtk/ofstd/diag/unarymin.def" // readable shorthands for compiler version checks #define DCMTK_DIAGNOSTIC_MIN_GCC_VERSION(MAJOR, MINOR, PATCH)\ diff --git a/ofstd/tests/tlimits.cc b/ofstd/tests/tlimits.cc index ab97a2e125..b4473fc578 100644 --- a/ofstd/tests/tlimits.cc +++ b/ofstd/tests/tlimits.cc @@ -30,7 +30,7 @@ #include "dcmtk/ofstd/ofmath.h" // for isinf and isnan // On some platforms, such as OpenIndiana, isinf is defined as a macro, -// and that inteferes with the OFMath function of the same name. +// and that interferes with the OFMath function of the same name. #ifdef isinf #undef isinf #endif @@ -38,6 +38,7 @@ #include DCMTK_DIAGNOSTIC_PUSH #include DCMTK_DIAGNOSTIC_IGNORE_OVERFLOW #include DCMTK_DIAGNOSTIC_IGNORE_IMPLICIT_CONVERSION +#include DCMTK_DIAGNOSTIC_IGNORE_UNSIGNED_UNARY_MINUS template static void checkMinMax() {