diff --git a/samples/geotag.cpp b/samples/geotag.cpp index b45099fd..2e98aeb8 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -19,10 +19,6 @@ using namespace std; -#ifndef lengthof -#define lengthof(x) (sizeof(*x) / sizeof(x)) -#endif - #if defined(_MSC_VER) || defined(__MINGW__) #include char* realpath(const char* file, char* path); diff --git a/samples/getopt-test.cpp b/samples/getopt-test.cpp index 261221c8..39aa93cf 100644 --- a/samples/getopt-test.cpp +++ b/samples/getopt-test.cpp @@ -31,7 +31,7 @@ #endif #include -#define Safe(x) (x ? x : "unknown") +#define Safe(x) ((x) ? (x) : "unknown") const char* optstring = ":hVvqfbuktTFa:Y:O:D:r:p:P:d:e:i:c:m:M:l:S:g:K:n:Q:"; // ***************************************************************************** diff --git a/src/http.cpp b/src/http.cpp index e8882ded..dc02eaa1 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -37,7 +37,7 @@ #define WINAPI using DWORD = unsigned long; -#define SOCKET_ERROR -1 +#define SOCKET_ERROR (-1) #define WSAEWOULDBLOCK EINPROGRESS #define WSAENOTCONN EAGAIN @@ -56,10 +56,10 @@ static constexpr auto httpTemplate = "%s" // $header "\r\n"; -#define white(c) ((c == ' ') || (c == '\t')) +#define white(c) (((c) == ' ') || ((c) == '\t')) -#define FINISH -999 -#define OK(s) (200 <= s && s < 300) +#define FINISH (-999) +#define OK(s) (200 <= (s) && (s) < 300) static constexpr std::array blankLines{ "\r\n\r\n", // this is the standard diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index 24c427a2..6101f8e1 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -12,8 +12,8 @@ #include // Shortcuts for the newTiffBinaryArray templates. -#define EXV_BINARY_ARRAY(arrayCfg, arrayDef) (newTiffBinaryArray0<&arrayCfg, std::size(arrayDef), arrayDef>) -#define EXV_SIMPLE_BINARY_ARRAY(arrayCfg) (newTiffBinaryArray1<&arrayCfg>) +#define EXV_BINARY_ARRAY(arrayCfg, arrayDef) (newTiffBinaryArray0<&(arrayCfg), std::size(arrayDef), arrayDef>) +#define EXV_SIMPLE_BINARY_ARRAY(arrayCfg) (newTiffBinaryArray1<&(arrayCfg)>) #define EXV_COMPLEX_BINARY_ARRAY(arraySet, cfgSelFct) (newTiffBinaryArray2) namespace Exiv2::Internal { diff --git a/src/version.cpp b/src/version.cpp index a9548cab..983771da 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -27,9 +27,6 @@ #include #endif -#ifndef lengthof -#define lengthof(x) sizeof(x) / sizeof(x[0]) -#endif #ifndef _MAX_PATH #define _MAX_PATH 512 #endif @@ -126,10 +123,10 @@ static std::vector getLoadedLibraries() { // enumerate loaded libraries and determine path to executable HMODULE handles[200]; DWORD cbNeeded; - if (EnumProcessModules(GetCurrentProcess(), handles, lengthof(handles), &cbNeeded)) { + if (EnumProcessModules(GetCurrentProcess(), handles, std::size(handles), &cbNeeded)) { char szFilename[_MAX_PATH]; for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) { - GetModuleFileNameA(handles[h], szFilename, lengthof(szFilename)); + GetModuleFileNameA(handles[h], szFilename, std::size(szFilename)); std::string path(szFilename); pushPath(path, libs, paths); }