diff --git a/app/actions.cpp b/app/actions.cpp index 698f74df1f..dc2234beba 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -31,7 +31,7 @@ #include // for stat() #endif -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) #include #include #include @@ -1669,7 +1669,7 @@ std::string temporaryPath() { static int count = 0; auto guard = std::scoped_lock(cs); -#if defined(_MSC_VER) || defined(__MINGW__) +#if defined(_WIN32) HANDLE process = 0; DWORD pid = ::GetProcessId(process); #else diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 08c8a66587..f9675b0777 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -21,7 +21,7 @@ #include #include -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) #include #include #include @@ -942,7 +942,7 @@ static size_t readFileToBuf(FILE* f, Exiv2::DataBuf& buf) { void Params::getStdin(Exiv2::DataBuf& buf) { // copy stdin to stdinBuf if (stdinBuf.empty()) { -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__) || defined(_MSC_VER) +#if defined(_WIN32) DWORD fdwMode; _setmode(fileno(stdin), O_BINARY); Sleep(300); @@ -1276,7 +1276,7 @@ bool parseCmdLines(ModifyCmds& modifyCmds, const Params::CmdLines& cmdLines) { } } // parseCmdLines -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 static std::string formatArg(const char* arg) { std::string result = ""; char b = ' '; @@ -1317,7 +1317,7 @@ bool parseLine(ModifyCmd& modifyCmd, const std::string& line, int num) { std::string::size_type keyEnd = line.find_first_of(delim, keyStart + 1); if (cmdEnd == std::string::npos || keyStart == std::string::npos) { std::string cmdLine; -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 for (int i = 1; i < __argc; i++) { cmdLine += std::string(" ") + formatArg(__argv[i]); } diff --git a/include/exiv2/config.h b/include/exiv2/config.h index bc23b45b7b..e55bd28bbb 100644 --- a/include/exiv2/config.h +++ b/include/exiv2/config.h @@ -40,7 +40,7 @@ #endif #ifndef __LITTLE_ENDIAN__ -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) +#if defined(_WIN32) || defined(__CYGWIN__) #define __LITTLE_ENDIAN__ 1 #endif #endif @@ -62,7 +62,7 @@ ///// Path separator macros ///// #ifndef EXV_SEPARATOR_STR -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) #define EXV_SEPARATOR_STR "\\" #define EXV_SEPARATOR_CHR '\\' #else diff --git a/samples/geotag.cpp b/samples/geotag.cpp index 2e98aeb828..e50023f513 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -11,15 +11,9 @@ #include #include -#if defined(__MINGW32__) || defined(__MINGW64__) -#ifndef __MINGW__ -#define __MINGW__ -#endif -#endif - using namespace std; -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 #include char* realpath(const char* file, char* path); #define lstat _stat @@ -384,7 +378,7 @@ int timeZoneAdjust() { [[maybe_unused]] time_t now = time(nullptr); int offset; -#if defined(_MSC_VER) || defined(__MINGW__) +#if defined(_WIN32) TIME_ZONE_INFORMATION TimeZoneInfo; GetTimeZoneInformation(&TimeZoneInfo); offset = -(((int)TimeZoneInfo.Bias + (int)TimeZoneInfo.DaylightBias) * 60); diff --git a/src/basicio.cpp b/src/basicio.cpp index 673c939921..d377e6d22b 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -37,7 +37,7 @@ #include #endif -#if defined(__MINGW__) || defined(_MSC_VER) +#ifdef _WIN32 #define mode_t unsigned short #include #include @@ -85,7 +85,7 @@ class FileIo::Impl { FILE* fp_{}; //!< File stream pointer OpMode opMode_{opSeek}; //!< File open mode -#if defined _WIN32 && !defined __CYGWIN__ +#if defined _WIN32 HANDLE hFile_{}; //!< Duplicated fd HANDLE hMap_{}; //!< Handle from CreateFileMapping #endif @@ -196,7 +196,7 @@ int FileIo::munmap() { if (::munmap(p_->pMappedArea_, p_->mappedLength_) != 0) { rc = 1; } -#elif defined _WIN32 && !defined __CYGWIN__ +#elif defined _WIN32 UnmapViewOfFile(p_->pMappedArea_); CloseHandle(p_->hMap_); p_->hMap_ = 0; @@ -243,7 +243,7 @@ byte* FileIo::mmap(bool isWriteable) { } p_->pMappedArea_ = static_cast(rc); -#elif defined _WIN32 && !defined __CYGWIN__ +#elif defined _WIN32 // Windows implementation // TODO: An attempt to map a file with a length of 0 (zero) fails with @@ -937,7 +937,7 @@ std::string XPathIo::writeDataToFile(const std::string& orgPath) { if (prot == pStdin) { if (isatty(fileno(stdin))) throw Error(ErrorCode::kerInputDataReadFailed); -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 // convert stdin to binary if (_setmode(_fileno(stdin), _O_BINARY) == -1) throw Error(ErrorCode::kerInputDataReadFailed); diff --git a/src/convert.cpp b/src/convert.cpp index 06b12a69ea..89ea4aa590 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -21,7 +21,7 @@ #include #include -#if defined _WIN32 && !defined __CYGWIN__ +#if defined _WIN32 #include #endif @@ -47,7 +47,7 @@ namespace { #if defined EXV_HAVE_ICONV // Convert string charset with iconv. bool convertStringCharsetIconv(std::string& str, const char* from, const char* to); -#elif defined _WIN32 && !defined __CYGWIN__ +#elif defined _WIN32 // Convert string charset with Windows functions. bool convertStringCharsetWindows(std::string& str, const char* from, const char* to); #endif @@ -1397,7 +1397,7 @@ bool convertStringCharset(std::string& str, const char* from, const char* to) { bool ret = false; #if defined EXV_HAVE_ICONV ret = convertStringCharsetIconv(str, from, to); -#elif defined _WIN32 && !defined __CYGWIN__ +#elif defined _WIN32 ret = convertStringCharsetWindows(str, from, to); #else #ifndef SUPPRESS_WARNINGS @@ -1413,7 +1413,7 @@ bool convertStringCharset(std::string& str, const char* from, const char* to) { namespace { using namespace Exiv2; -#if defined _WIN32 && !defined __CYGWIN__ +#if defined _WIN32 bool swapBytes(std::string& str) { // Naive byte-swapping, I'm sure this can be done more efficiently if (str.size() & 1) { @@ -1558,7 +1558,7 @@ const ConvFctList convFctList[] = { return ret; } -#endif // defined _WIN32 && !defined __CYGWIN__ +#endif // defined _WIN32 #if defined EXV_HAVE_ICONV bool convertStringCharsetIconv(std::string& str, const char* from, const char* to) { if (0 == strcmp(from, to)) diff --git a/src/http.cpp b/src/http.cpp index 44b5503bf5..e1fa9121f7 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -2,7 +2,7 @@ #include "config.h" -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) +#if defined(_WIN32) || defined(__CYGWIN__) #define __USE_W32_SOCKETS #include #endif @@ -18,7 +18,7 @@ //////////////////////////////////////// // platform specific code -#if defined(__CYGWIN__) || defined(_MSC_VER) || defined(__MINGW__) +#if defined(_WIN32) || defined(__CYGWIN__) #else //////////////////////////////////////// // Unix or Mac @@ -122,7 +122,7 @@ static Exiv2::Dictionary stringToDict(const std::string& s) { } static int makeNonBlocking(int sockfd) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) ULONG ioctl_opt = 1; return ioctlsocket(sockfd, FIONBIO, &ioctl_opt); #else @@ -147,7 +147,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st //////////////////////////////////// // Windows specific code -#if defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); #endif diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 2cc7fb42d4..dc94478a4f 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -21,7 +21,7 @@ namespace fs = std::filesystem; -#if !defined(_MSC_VER) && !defined(__MINGW__) +#if !defined(_WIN32) #include #include #else @@ -54,7 +54,7 @@ namespace Exiv2::Internal { // If not found in cwd, we return the default path // which is the user profile path on win and the home dir on linux std::string getExiv2ConfigPath() { -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 std::string inifile("exiv2.ini"); #else std::string inifile(".exiv2"); @@ -65,7 +65,7 @@ std::string getExiv2ConfigPath() { return iniPath.string(); } -#if defined(_MSC_VER) || defined(__MINGW__) +#ifdef _WIN32 char buffer[1024]; if (SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_PROFILE, nullptr, 0, buffer))) { currentPath = buffer; diff --git a/src/version.cpp b/src/version.cpp index 15fd1d7794..04f5fcb786 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -32,7 +32,7 @@ #endif // platform specific support for getLoadedLibraries -#if defined(__CYGWIN__) || defined(__MINGW__) || defined(_WIN32) +#if defined(_WIN32) || defined(__CYGWIN__) // clang-format off #include #include @@ -119,7 +119,7 @@ static std::vector getLoadedLibraries() { std::set paths; std::string path; -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__) +#if defined(_WIN32) || defined(__CYGWIN__) // enumerate loaded libraries and determine path to executable HMODULE handles[200]; DWORD cbNeeded;