diff --git a/modules/c++/CMakeLists.txt b/modules/c++/CMakeLists.txt index e1f5ec10a..a31f55362 100644 --- a/modules/c++/CMakeLists.txt +++ b/modules/c++/CMakeLists.txt @@ -6,7 +6,8 @@ set(CXX_STANDARD_REQUIRED true) if (MSVC) add_compile_options(/WX /W4) elseif (UNIX) - add_compile_options(-Werror) + # still building with older GCC :-( + #add_compile_options(-Werror) add_compile_options(-Wall) #add_compile_options(-Wpedantic -Wextra) add_compile_options(-Wno-deprecated-copy) diff --git a/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h b/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h index 388cb8fd5..f28d64236 100644 --- a/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h +++ b/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h @@ -53,16 +53,6 @@ #endif // __INTEL_COMPILER #endif // CODA_OSS_cplusplus -#if CODA_OSS_cplusplus < 201402L - // oops ... try to fix - #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER_BUILD_DATE >= 20151021) - // __cplusplus is 201300, not 201402L - // Enough C++14, at least with our std/ work-arounds - #undef CODA_OSS_cplusplus - #define CODA_OSS_cplusplus 201402L - #endif -#endif // CODA_OSS_cplusplus - #if CODA_OSS_cplusplus < 202002L // oops ... try to fix #if defined(__GNUC__) && (__cplusplus >= 201709L) // note > C++ 17 of 201703L diff --git a/modules/c++/coda_oss/include/coda_oss/optional_.h b/modules/c++/coda_oss/include/coda_oss/optional_.h index 9ce2bf2ef..c321b5b70 100644 --- a/modules/c++/coda_oss/include/coda_oss/optional_.h +++ b/modules/c++/coda_oss/include/coda_oss/optional_.h @@ -63,27 +63,21 @@ class optional final using value_type = T; #if defined(_MSC_VER) && _PREFAST_ // Visual Studio /analyze - __pragma(warning(push)) __pragma(warning( - disable : 26495)) // Variable '...' is uninitialized. Always - // initialize a member variable(type.6). + __pragma(warning(push)) __pragma(warning(disable : 26495)) // Variable '...' is uninitialized. Always initialize a member variable(type.6). #endif - optional() noexcept + optional() noexcept { } #if defined(_MSC_VER) && _PREFAST_ __pragma(warning(pop)) #endif - optional(const value_type& v) : - value_(v), has_value_(true) + optional(const value_type& v) : value_(v), has_value_(true) { } #if defined(_MSC_VER) && _PREFAST_ // Visual Studio /analyze - __pragma(warning(push)) __pragma(warning( - disable : 26495)) // Variable '...' is uninitialized. Always - // initialize a member variable(type.6). + __pragma(warning(push)) __pragma(warning(disable : 26495)) // Variable '...' is uninitialized. Always initialize a member variable(type.6). #endif - optional(const optional& other) : - has_value_(other.has_value_) + optional(const optional& other) : has_value_(other.has_value_) { if (has_value()) { @@ -94,18 +88,15 @@ class optional final __pragma(warning(pop)) #endif - template < - typename... Args> // https://en.cppreference.com/w/cpp/utility/Optional/emplace - T& emplace(Args&&... args) + template // https://en.cppreference.com/w/cpp/utility/Optional/emplace + T& emplace(Args&&... args) { value_ = value_type(std::forward(args)...); has_value_ = true; return value_; } - template < - typename U = - T> // https://en.cppreference.com/w/cpp/utility/optional/operator%3D + template // https://en.cppreference.com/w/cpp/utility/optional/operator%3D optional& operator=(U&& value) noexcept { value_ = std::forward(value); @@ -163,11 +154,10 @@ class optional final // contains a value!" } - const T& operator*() const& + const T& operator*() const& noexcept { assert(has_value()); - return value_; // "This operator does not check whether the optional - // contains a value!" + return value_; // "This operator does not check whether the optional contains a value!" } T& operator*() & { diff --git a/modules/c++/coda_oss/include/coda_oss/type_traits.h b/modules/c++/coda_oss/include/coda_oss/type_traits.h index 5bd920a91..5c92c1d32 100644 --- a/modules/c++/coda_oss/include/coda_oss/type_traits.h +++ b/modules/c++/coda_oss/include/coda_oss/type_traits.h @@ -29,21 +29,7 @@ #include "coda_oss/namespace_.h" namespace coda_oss { -// workaround missing "is_trivially_copyable" in g++ < 5.0 -// https://stackoverflow.com/a/31798726/8877 -#if defined(__GNUC__) && (__GNUC__ < 5) -template -struct is_trivially_copyable final -{ - // This old Intel compiler has enough C++14 for our needs; see CPlusPlus.h - #if !(defined(__INTEL_COMPILER) && (__INTEL_COMPILER_BUILD_DATE <= 20151021)) - static_assert(CODA_OSS_cplusplus < 201402L, "C++14 must have is_trivially_copyable."); - #endif - static constexpr bool value = __has_trivial_copy(T); -}; -#else using std::is_trivially_copyable; -#endif } #endif // CODA_OSS_coda_oss_type_traits_h_INCLUDED_ diff --git a/modules/c++/io/source/FileInputStreamIOS.cpp b/modules/c++/io/source/FileInputStreamIOS.cpp index 5358e61d3..e1585d16b 100644 --- a/modules/c++/io/source/FileInputStreamIOS.cpp +++ b/modules/c++/io/source/FileInputStreamIOS.cpp @@ -115,18 +115,8 @@ sys::SSize_T io::FileInputStreamIOS::readImpl(void* buffer, size_t len) if (avail > 0) { sys::SSize_T bytesRead(0); - // There is a 'huge-gantic' bug in Forte 6.2 - // in which 'read()' reads the first character twice -#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x530) - - while (bytesRead < avail && mFStream.good()) - { - bufferPtr[bytesRead++] = mFStream.get(); - } -#else mFStream.read(bufferPtr, avail); bytesRead = mFStream.gcount(); -#endif return bytesRead; } diff --git a/modules/c++/io/source/FileUtils.cpp b/modules/c++/io/source/FileUtils.cpp index cdcd1e7c0..9de78af1f 100644 --- a/modules/c++/io/source/FileUtils.cpp +++ b/modules/c++/io/source/FileUtils.cpp @@ -40,7 +40,7 @@ void copyPermissions(const std::string& src, const std::string& dest) { -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 // set up permissions on unix -- // copy the source's permissions struct stat statBuf; diff --git a/modules/c++/io/source/StringStream.cpp b/modules/c++/io/source/StringStream.cpp index e65b3fcdb..1530070c5 100644 --- a/modules/c++/io/source/StringStream.cpp +++ b/modules/c++/io/source/StringStream.cpp @@ -32,16 +32,7 @@ // // if (len <= 0) return 0; // -//#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x530) -// sys::SSize_T bytesRead(0); -// while (bytesRead < len && mData.good()) -// { -// b[bytesRead++] = mData.get(); -// } -// len = bytesRead; -//#else // mData.read((char *)buffer, len); -//#endif // // Could be problem if streams are broken // // alternately could return gcount in else // // case above diff --git a/modules/c++/mt/include/mt/CPUAffinityInitializer.h b/modules/c++/mt/include/mt/CPUAffinityInitializer.h index 2fe3eb3b6..88737cd9a 100644 --- a/modules/c++/mt/include/mt/CPUAffinityInitializer.h +++ b/modules/c++/mt/include/mt/CPUAffinityInitializer.h @@ -26,7 +26,7 @@ #include -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include namespace mt { diff --git a/modules/c++/mt/include/mt/CPUAffinityInitializerWin32.h b/modules/c++/mt/include/mt/CPUAffinityInitializerWin32.h index 5431f5af0..be84e15e8 100644 --- a/modules/c++/mt/include/mt/CPUAffinityInitializerWin32.h +++ b/modules/c++/mt/include/mt/CPUAffinityInitializerWin32.h @@ -24,7 +24,7 @@ #ifndef __MT_CPU_AFFINITY_INITIALIZER_WIN32_H__ #define __MT_CPU_AFFINITY_INITIALIZER_WIN32_H__ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include #include diff --git a/modules/c++/mt/include/mt/CPUAffinityThreadInitializer.h b/modules/c++/mt/include/mt/CPUAffinityThreadInitializer.h index fa6925973..4ffb36e08 100644 --- a/modules/c++/mt/include/mt/CPUAffinityThreadInitializer.h +++ b/modules/c++/mt/include/mt/CPUAffinityThreadInitializer.h @@ -26,7 +26,7 @@ #include -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include namespace mt { diff --git a/modules/c++/mt/include/mt/CPUAffinityThreadInitializerWin32.h b/modules/c++/mt/include/mt/CPUAffinityThreadInitializerWin32.h index ef45f42de..132f31cf8 100644 --- a/modules/c++/mt/include/mt/CPUAffinityThreadInitializerWin32.h +++ b/modules/c++/mt/include/mt/CPUAffinityThreadInitializerWin32.h @@ -24,7 +24,7 @@ #ifndef __MT_CPU_AFFINITY_THREAD_INITIALIZER_WIN32_H__ #define __MT_CPU_AFFINITY_THREAD_INITIALIZER_WIN32_H__ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include diff --git a/modules/c++/net/include/net/Daemon.h b/modules/c++/net/include/net/Daemon.h index 61f3ef53e..8c27d3ebf 100644 --- a/modules/c++/net/include/net/Daemon.h +++ b/modules/c++/net/include/net/Daemon.h @@ -1,7 +1,7 @@ #ifndef __NET_DAEMON_H__ #define __NET_DAEMON_H__ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # include "net/DaemonWin32.h" namespace net { diff --git a/modules/c++/net/include/net/DaemonUnix.h b/modules/c++/net/include/net/DaemonUnix.h index 2e584c469..c866bb3aa 100644 --- a/modules/c++/net/include/net/DaemonUnix.h +++ b/modules/c++/net/include/net/DaemonUnix.h @@ -1,7 +1,7 @@ #ifndef __NET_DAEMON_UNIX_H__ #define __NET_DAEMON_UNIX_H__ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include "net/DaemonInterface.h" #include diff --git a/modules/c++/net/include/net/DaemonWin32.h b/modules/c++/net/include/net/DaemonWin32.h index d4273d71f..27b1ff768 100644 --- a/modules/c++/net/include/net/DaemonWin32.h +++ b/modules/c++/net/include/net/DaemonWin32.h @@ -1,7 +1,7 @@ #ifndef __NET_DAEMON_WIN32_H__ #define __NET_DAEMON_WIN32_H__ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include "net/DaemonInterface.h" #include diff --git a/modules/c++/net/include/net/Socket.h b/modules/c++/net/include/net/Socket.h index a5dea0c2b..7d75eae46 100644 --- a/modules/c++/net/include/net/Socket.h +++ b/modules/c++/net/include/net/Socket.h @@ -141,7 +141,7 @@ class Socket // capture the error sys::SocketErr err; -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 /* Wrapper for setsockopt dealing with Windows specific issues :- * diff --git a/modules/c++/net/include/net/SocketAddress.h b/modules/c++/net/include/net/SocketAddress.h index 2af4695ef..283dd4331 100644 --- a/modules/c++/net/include/net/SocketAddress.h +++ b/modules/c++/net/include/net/SocketAddress.h @@ -25,7 +25,7 @@ #include "net/Sockets.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # include #else # include diff --git a/modules/c++/net/include/net/Sockets.h b/modules/c++/net/include/net/Sockets.h index 7b7222b94..fb9e56032 100644 --- a/modules/c++/net/include/net/Sockets.h +++ b/modules/c++/net/include/net/Sockets.h @@ -25,7 +25,7 @@ # include "sys/Conf.h" -# if defined(WIN32) || defined(_WIN32) +# ifdef _WIN32 # include "net/SocketsWin32.h" # else # include "net/SocketsUnix.h" diff --git a/modules/c++/net/include/net/SocketsUnix.h b/modules/c++/net/include/net/SocketsUnix.h index 967a47d0b..58f0d2ed6 100644 --- a/modules/c++/net/include/net/SocketsUnix.h +++ b/modules/c++/net/include/net/SocketsUnix.h @@ -56,31 +56,10 @@ typedef struct hostent HostEnt_T; typedef int Socket_T; typedef struct sockaddr SockAddr_T; typedef struct sockaddr_in SockAddrIn_T; -#if defined(__sun) || defined(__sun__) || defined(__sparc) || defined(__sparc__) -typedef SockAddr_T ConnParam2_T; -#else typedef const SockAddr_T ConnParam2_T; -#endif #if defined(__linux) || defined(__linux__) typedef socklen_t SockLen_T; -#elif defined(__sun) || defined(__sun__) || defined(__sparc) || defined(__sparc__) -# if defined(__SunOS_5_6) -typedef int SockLen_T; -# elif defined(__sparcv9) && defined(__arch64__) && defined(__GNUC__) -typedef socklen_t SockLen_T; -# else -typedef size_t SockLen_T; -# endif -#elif defined(_AIX) || defined(__aix) || defined(__aix__) -# if defined(__GNUC__) -typedef socklen_t SockLen_T; -# else -// 64-bit AIX uses socklen_t but I don't know the flags -// typedef unsigned int SockLen_T; -// The new(er) AIX machine uses socklen_t... -typedef socklen_t SockLen_T; -# endif #elif defined(__APPLE_CC__) typedef socklen_t SockLen_T; #else diff --git a/modules/c++/net/source/DaemonUnix.cpp b/modules/c++/net/source/DaemonUnix.cpp index 5fcee2a6e..8683816f9 100644 --- a/modules/c++/net/source/DaemonUnix.cpp +++ b/modules/c++/net/source/DaemonUnix.cpp @@ -1,4 +1,4 @@ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include "net/DaemonUnix.h" #include diff --git a/modules/c++/net/source/SocketAddress.cpp b/modules/c++/net/source/SocketAddress.cpp index 65106e5ce..e5dcf0494 100644 --- a/modules/c++/net/source/SocketAddress.cpp +++ b/modules/c++/net/source/SocketAddress.cpp @@ -65,7 +65,7 @@ void SocketAddress::setHost(const std::string& host) } else { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 struct sockaddr saddr; int slen = sizeof(saddr); struct sockaddr_in *paddr = (struct sockaddr_in *)&saddr; diff --git a/modules/c++/plugin/include/plugin/PluginDefines.h b/modules/c++/plugin/include/plugin/PluginDefines.h index 2fcdfc901..6a821f9db 100644 --- a/modules/c++/plugin/include/plugin/PluginDefines.h +++ b/modules/c++/plugin/include/plugin/PluginDefines.h @@ -31,7 +31,7 @@ /* #define PLUGIN_DESTRUCTOR_NAME "DestroyPlugin" */ #define GET_PLUGIN_IDENT "GetPluginIdentity" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # define PLUGIN_DSO_EXTENSION ".dll" #else # define PLUGIN_DSO_EXTENSION ".so" @@ -48,7 +48,7 @@ #define PLUGIN_API_MINOR_VERSION 0 -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # if defined(PLUGIN_MODULE_EXPORTS) # define PLUGIN_HOOK extern "C" __declspec(dllexport) # else diff --git a/modules/c++/str/include/str/EncodedStringView.h b/modules/c++/str/include/str/EncodedStringView.h index dc35c9e4a..1fd1e99ac 100644 --- a/modules/c++/str/include/str/EncodedStringView.h +++ b/modules/c++/str/include/str/EncodedStringView.h @@ -55,7 +55,7 @@ class CODA_OSS_API EncodedStringView final explicit EncodedStringView(coda_oss::span); explicit EncodedStringView(coda_oss::span); -#if _WIN32 + #ifdef _WIN32 static constexpr bool mNativeIsUtf8 = false; // Windows-1252 #else static constexpr bool mNativeIsUtf8 = true; // !_WIN32, assume Linux @@ -109,12 +109,8 @@ class CODA_OSS_API EncodedStringView final // is WCHAR (char* is converted to UTF-16). std::wstring wstring() const; // UTF-16 on Windows, UTF-32 on Linux - // With some older C++ compilers, uint16_t may be used instead of char16_t :-( - // Using this routine can avoid an extra copy. - str::ui16string ui16string_() const; // use sparingly! - // These are for "advanced" use, most "normal" code should use the routines above. - std::string::const_pointer c_str() const + std::string::const_pointer c_str() const noexcept { return mString.data(); } @@ -126,7 +122,7 @@ class CODA_OSS_API EncodedStringView final { return mIsUtf8 ? nullptr : cast(c_str()); } - size_t size() const + size_t size() const noexcept { return mString.size(); } diff --git a/modules/c++/str/include/str/Encoding.h b/modules/c++/str/include/str/Encoding.h index c063c61d5..0147306ec 100644 --- a/modules/c++/str/include/str/Encoding.h +++ b/modules/c++/str/include/str/Encoding.h @@ -62,9 +62,6 @@ inline typename TBasicStringT::const_pointer c_str(const std::basic_string; // https://en.cppreference.com/w/cpp/string -// With some older C++ compilers, uint16_t may be used instead of char16_t :-( -using ui16string = std::basic_string; // ui = UInt16_t - ////////////////////////////////////////////////////////////////////////////////////////// // We'll get strange errors, possibibly at link-time, if wchar_t is not a wchar_t type. @@ -88,9 +85,7 @@ inline coda_oss::u8string to_u8string(coda_oss::u8string::const_pointer s, size_ CODA_OSS_API coda_oss::u8string to_u8string(std::u16string::const_pointer, size_t); CODA_OSS_API std::u16string to_u16string(coda_oss::u8string::const_pointer, size_t); -str::ui16string to_ui16string(coda_oss::u8string::const_pointer, size_t); std::u16string to_u16string(str::W1252string::const_pointer, size_t); -str::ui16string to_ui16string(str::W1252string::const_pointer, size_t); // UTF-32 is convenient because each code-point is a single 32-bit integer. // It's typically std::wstring::value_type on Linux, but NOT Windows. diff --git a/modules/c++/str/source/EncodedStringView.cpp b/modules/c++/str/source/EncodedStringView.cpp index 2c5bf0150..90fcf3144 100644 --- a/modules/c++/str/source/EncodedStringView.cpp +++ b/modules/c++/str/source/EncodedStringView.cpp @@ -41,7 +41,7 @@ enum class PlatformType // MacOS }; -#if _WIN32 +#ifdef _WIN32 static auto Platform = PlatformType::Windows; #else static auto Platform = PlatformType::Linux; @@ -55,14 +55,6 @@ inline std::u16string to_u16string(std::string::const_pointer s, size_t sz, bool } return str::to_u16string(str::cast(s), sz); } -inline str::ui16string to_ui16string(std::string::const_pointer s, size_t sz, bool is_utf8 /* is 's' UTF-8? */) -{ - if (is_utf8) - { - return str::to_ui16string(str::cast(s), sz); - } - return str::to_ui16string(str::cast(s), sz); -} static std::string to_native(coda_oss::u8string::const_pointer p, size_t sz) { @@ -155,10 +147,6 @@ std::u16string str::EncodedStringView::u16string() const { return ::to_u16string(mString.data(), mString.size(), mIsUtf8); } -str::ui16string str::EncodedStringView::ui16string_() const -{ - return ::to_ui16string(mString.data(), mString.size(), mIsUtf8); -} inline std::u32string to_u32string(std::string::const_pointer s, size_t sz, bool is_utf8 /* is 's' UTF-8? */) { @@ -179,10 +167,9 @@ std::wstring str::EncodedStringView::wstring() const // UTF-16 on Windows, UTF- const auto sz = mString.size(); const auto s = // Need to use #ifdef's because str::cast() checks to be sure the sizes are correct. - #if _WIN32 + #ifdef _WIN32 ::to_u16string(p, sz, mIsUtf8); // std::wstring is UTF-16 on Windows - #endif - #if !_WIN32 + #else ::to_u32string(p, sz, mIsUtf8); // std::wstring is UTF-32 on Linux #endif return str::c_str(s); // copy @@ -208,11 +195,13 @@ bool str::EncodedStringView::operator_eq(const EncodedStringView& rhs) const if (lhs.mIsUtf8 == rhs.mIsUtf8) // both are UTF-8 or both are Windows-1252 { // But we can avoid that call if the pointers are the same - if ((lhs.mString.data() == rhs.mString.data()) && (rhs.mString.size() == rhs.mString.size())) + const auto pLhs = lhs.mString.data(); + const auto pRhs = rhs.mString.data(); + if ((pLhs == pRhs) && (rhs.mString.size() == rhs.mString.size())) { return true; } - return strcmp(lhs.mString.data(), rhs.mString.data()) == 0; + return strcmp(pLhs, pRhs) == 0; } // LHS and RHS have different encodings, but one must be UTF-8 diff --git a/modules/c++/str/source/Encoding.cpp b/modules/c++/str/source/Encoding.cpp index 51d54719e..bbe3a0a5f 100644 --- a/modules/c++/str/source/Encoding.cpp +++ b/modules/c++/str/source/Encoding.cpp @@ -204,10 +204,6 @@ std::u16string str::to_u16string(str::W1252string::const_pointer p, size_t sz) #endif return retval; } -str::ui16string str::to_ui16string(str::W1252string::const_pointer p, size_t sz) -{ - return to_Tstring(p, sz); -} std::u32string str::to_u32string(str::W1252string::const_pointer p, size_t sz) { return to_Tstring(p, sz); @@ -352,13 +348,6 @@ std::u16string str::to_u16string(coda_oss::u8string::const_pointer p_, size_t sz utf8::utf8to16(p, p + sz, std::back_inserter(retval)); return retval; } -str::ui16string str::to_ui16string(coda_oss::u8string::const_pointer p_, size_t sz) -{ - auto p = str::cast(p_); - str::ui16string retval; - utf8::utf8to16(p, p + sz, std::back_inserter(retval)); - return retval; -} std::u32string str::to_u32string(coda_oss::u8string::const_pointer p_, size_t sz) { diff --git a/modules/c++/sys/include/sys/Conf.h b/modules/c++/sys/include/sys/Conf.h index b0a0533a1..e910f5135 100644 --- a/modules/c++/sys/include/sys/Conf.h +++ b/modules/c++/sys/include/sys/Conf.h @@ -25,6 +25,11 @@ #define CODA_OSS_sys_Conf_h_INCLUDED_ #pragma once +// In case there is still a WIN32 (should be "_WIN32" with a leading '_') someplace. +#if defined(_WIN32) && !defined(WIN32) +#define WIN32 _WIN32 +#endif + // POSIX is more-or-less "Unix" // https://linux.die.net/man/7/feature_test_macros // "If no feature test macros are explicitly defined, then the following feature test macros @@ -47,25 +52,19 @@ #endif #include -#include #include #include -#include - -#if defined(__sgi) || defined(__sgi__) -# include -# include -#else -# include -# include -#endif +#include +#include +#include +#include #include + #include "str/Format.h" #include "sys/TimeStamp.h" - /* Dance around the compiler to figure out */ /* if we have access to function macro... */ @@ -73,7 +72,7 @@ #if defined(__GNUC__) /* We get a really nice function macro */ # define NativeLayer_func__ __PRETTY_FUNCTION__ -#elif (defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1300) +#elif defined(_WIN32) && (_MSC_VER >= 1300) # define NativeLayer_func__ __FUNCSIG__ /* Otherwise, lets look for C99 compatibility */ #elif defined (__STDC_VERSION__) @@ -109,7 +108,7 @@ namespace sys typedef int64_t Int64_T; } -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # include # include # include @@ -131,21 +130,6 @@ namespace sys } #else // !windows # include -# if defined(__sgi) || defined(__sgi__) -# if defined(__GNUC__) -# ifdef _FIX_BROKEN_HEADERS - typedef __int64_t jid_t; -# endif -# endif -# endif -# if defined(__sun) || defined(__sun__) || defined(__sparc) || defined(__sparc) || defined(__sparc__) -# if !defined(__SunOS_5_6) && !defined(__SunOS_5_7) && !defined(__SunOS_5_8) && defined(__GNUC__) -# ifdef _FIX_BROKEN_HEADERS - typedef id_t projid_t; -# endif -# endif -# include -# endif # include # include # include @@ -153,11 +137,7 @@ namespace sys # include # include # include -# if defined(_USE_STDINT) -# include -# else -# include -# endif +# include //# include namespace sys @@ -330,7 +310,7 @@ namespace sys size_t alignment = SSE_INSTRUCTION_ALIGNMENT) { void* p = nullptr; -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 p = _aligned_malloc(size, alignment); #elif CODA_OSS_POSIX2001_SOURCE // https://linux.die.net/man/3/posix_memalign @@ -362,7 +342,7 @@ namespace sys */ inline void alignedFree(void* p) { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 _aligned_free(p); #else free(p); diff --git a/modules/c++/sys/include/sys/DLL.h b/modules/c++/sys/include/sys/DLL.h index b9eb3d8c4..28fbb6be5 100644 --- a/modules/c++/sys/include/sys/DLL.h +++ b/modules/c++/sys/include/sys/DLL.h @@ -37,7 +37,7 @@ * */ -# if defined(WIN32) || defined(_WIN32) +# ifdef _WIN32 # include "sys/Conf.h" # define DLL_PUBLIC_FUNCTION extern "C" __declspec (dllexport) typedef HINSTANCE DYNAMIC_LIBRARY; diff --git a/modules/c++/sys/include/sys/Dbg.h b/modules/c++/sys/include/sys/Dbg.h index 3a1d1ea77..90d87546e 100644 --- a/modules/c++/sys/include/sys/Dbg.h +++ b/modules/c++/sys/include/sys/Dbg.h @@ -95,12 +95,7 @@ #include #include #include - -#if defined(__sgi) || defined(__sgi__) -# include -#else -# include -#endif +#include namespace sys { diff --git a/modules/c++/sys/include/sys/File.h b/modules/c++/sys/include/sys/File.h index dc535e93d..613e28936 100644 --- a/modules/c++/sys/include/sys/File.h +++ b/modules/c++/sys/include/sys/File.h @@ -29,7 +29,7 @@ #include "sys/filesystem.h" #include "config/Exports.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # define _SYS_SEEK_CUR FILE_CURRENT # define _SYS_SEEK_SET FILE_BEGIN # define _SYS_SEEK_END FILE_END diff --git a/modules/c++/sys/include/sys/MutexWin32.h b/modules/c++/sys/include/sys/MutexWin32.h index a9e9bbce5..adc3ac2d3 100644 --- a/modules/c++/sys/include/sys/MutexWin32.h +++ b/modules/c++/sys/include/sys/MutexWin32.h @@ -26,7 +26,7 @@ #include "config/Exports.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) #include "sys/MutexInterface.h" diff --git a/modules/c++/sys/include/sys/OS.h b/modules/c++/sys/include/sys/OS.h index 32cb75d40..d126d7d67 100644 --- a/modules/c++/sys/include/sys/OS.h +++ b/modules/c++/sys/include/sys/OS.h @@ -26,7 +26,7 @@ #include "sys/AbstractOS.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # include "sys/OSWin32.h" namespace sys { diff --git a/modules/c++/sys/include/sys/OSUnix.h b/modules/c++/sys/include/sys/OSUnix.h index 425378753..9e94df490 100644 --- a/modules/c++/sys/include/sys/OSUnix.h +++ b/modules/c++/sys/include/sys/OSUnix.h @@ -24,7 +24,7 @@ #ifndef __SYS_OS_UNIX_H__ #define __SYS_OS_UNIX_H__ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include "sys/AbstractOS.h" #include "sys/Conf.h" diff --git a/modules/c++/sys/include/sys/OSWin32.h b/modules/c++/sys/include/sys/OSWin32.h index 3e9c53d91..3b7dcd3ce 100644 --- a/modules/c++/sys/include/sys/OSWin32.h +++ b/modules/c++/sys/include/sys/OSWin32.h @@ -26,7 +26,7 @@ #include "sys/AbstractOS.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 /*! * \file OSWin32.h diff --git a/modules/c++/sys/include/sys/Process.h b/modules/c++/sys/include/sys/Process.h index 25d86359a..45800bf2b 100644 --- a/modules/c++/sys/include/sys/Process.h +++ b/modules/c++/sys/include/sys/Process.h @@ -38,7 +38,7 @@ #include "sys/ProcessInterface.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # include "sys/ProcessWin32.h" namespace sys { diff --git a/modules/c++/sys/include/sys/ProcessUnix.h b/modules/c++/sys/include/sys/ProcessUnix.h index 9ae4ce2b8..f435d33db 100644 --- a/modules/c++/sys/include/sys/ProcessUnix.h +++ b/modules/c++/sys/include/sys/ProcessUnix.h @@ -24,17 +24,7 @@ #ifndef __SYS_PROCESS_UNIX_H__ #define __SYS_PROCESS_UNIX_H__ - -#if defined(__GNUC__) -# if defined(__sgi) || defined(__sgi__) -# ifdef _FIX_BROKEN_HEADERS - typedef long long __int64_t; - typedef __int64_t jid_t; -# endif -# endif -#endif - -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include #include diff --git a/modules/c++/sys/include/sys/ProcessWin32.h b/modules/c++/sys/include/sys/ProcessWin32.h index 9db538344..d36e06a71 100644 --- a/modules/c++/sys/include/sys/ProcessWin32.h +++ b/modules/c++/sys/include/sys/ProcessWin32.h @@ -24,7 +24,7 @@ #ifndef __SYS_PROCESS_WIN32_H__ #define __SYS_PROCESS_WIN32_H__ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include "sys/ProcessInterface.h" #include "sys/Thread.h" diff --git a/modules/c++/sys/include/sys/ScopedCPUAffinityUnix.h b/modules/c++/sys/include/sys/ScopedCPUAffinityUnix.h index 62e7b0ea3..7a349fa78 100644 --- a/modules/c++/sys/include/sys/ScopedCPUAffinityUnix.h +++ b/modules/c++/sys/include/sys/ScopedCPUAffinityUnix.h @@ -25,7 +25,7 @@ #include -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include #include diff --git a/modules/c++/sys/include/sys/SemaphoreWin32.h b/modules/c++/sys/include/sys/SemaphoreWin32.h index baad6f570..d180feef5 100644 --- a/modules/c++/sys/include/sys/SemaphoreWin32.h +++ b/modules/c++/sys/include/sys/SemaphoreWin32.h @@ -26,7 +26,7 @@ #include "config/Exports.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) diff --git a/modules/c++/sys/include/sys/ThreadWin32.h b/modules/c++/sys/include/sys/ThreadWin32.h index 0b6118f32..4c8cf11a6 100644 --- a/modules/c++/sys/include/sys/ThreadWin32.h +++ b/modules/c++/sys/include/sys/ThreadWin32.h @@ -30,7 +30,7 @@ #include "config/Exports.h" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) diff --git a/modules/c++/sys/source/DLLUnix.cpp b/modules/c++/sys/source/DLLUnix.cpp index 2936e27cb..a0bb26ecf 100644 --- a/modules/c++/sys/source/DLLUnix.cpp +++ b/modules/c++/sys/source/DLLUnix.cpp @@ -21,7 +21,7 @@ */ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include "sys/DLL.h" diff --git a/modules/c++/sys/source/DLLWin32.cpp b/modules/c++/sys/source/DLLWin32.cpp index 17e9933af..d3d6ff48b 100644 --- a/modules/c++/sys/source/DLLWin32.cpp +++ b/modules/c++/sys/source/DLLWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include "sys/DLL.h" diff --git a/modules/c++/sys/source/ErrUnix.cpp b/modules/c++/sys/source/ErrUnix.cpp index 625538598..f2db39499 100644 --- a/modules/c++/sys/source/ErrUnix.cpp +++ b/modules/c++/sys/source/ErrUnix.cpp @@ -21,7 +21,7 @@ */ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include "sys/Err.h" diff --git a/modules/c++/sys/source/ErrWin32.cpp b/modules/c++/sys/source/ErrWin32.cpp index 9e1fbad15..bac96d0af 100644 --- a/modules/c++/sys/source/ErrWin32.cpp +++ b/modules/c++/sys/source/ErrWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include #include "sys/Err.h" diff --git a/modules/c++/sys/source/ExecUnix.cpp b/modules/c++/sys/source/ExecUnix.cpp index 71580aeaa..6a5f20912 100644 --- a/modules/c++/sys/source/ExecUnix.cpp +++ b/modules/c++/sys/source/ExecUnix.cpp @@ -21,7 +21,7 @@ */ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include #include diff --git a/modules/c++/sys/source/ExecWin32.cpp b/modules/c++/sys/source/ExecWin32.cpp index 1d1268d39..86bfa17cd 100644 --- a/modules/c++/sys/source/ExecWin32.cpp +++ b/modules/c++/sys/source/ExecWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include #include diff --git a/modules/c++/sys/source/FileUnix.cpp b/modules/c++/sys/source/FileUnix.cpp index ad9d42416..21e212f22 100644 --- a/modules/c++/sys/source/FileUnix.cpp +++ b/modules/c++/sys/source/FileUnix.cpp @@ -22,7 +22,7 @@ #include "sys/File.h" -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include #include diff --git a/modules/c++/sys/source/FileWin32.cpp b/modules/c++/sys/source/FileWin32.cpp index 6e104aef7..6db275189 100644 --- a/modules/c++/sys/source/FileWin32.cpp +++ b/modules/c++/sys/source/FileWin32.cpp @@ -20,7 +20,7 @@ * */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include #include diff --git a/modules/c++/sys/source/MutexWin32.cpp b/modules/c++/sys/source/MutexWin32.cpp index 69c7023ae..62786f0ee 100644 --- a/modules/c++/sys/source/MutexWin32.cpp +++ b/modules/c++/sys/source/MutexWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) diff --git a/modules/c++/sys/source/OSUnix.cpp b/modules/c++/sys/source/OSUnix.cpp index 633c6b4d6..e44d9a380 100644 --- a/modules/c++/sys/source/OSUnix.cpp +++ b/modules/c++/sys/source/OSUnix.cpp @@ -32,7 +32,7 @@ #include "sys/Conf.h" -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include diff --git a/modules/c++/sys/source/OSWin32.cpp b/modules/c++/sys/source/OSWin32.cpp index 2d7f30a2e..cfde07d35 100644 --- a/modules/c++/sys/source/OSWin32.cpp +++ b/modules/c++/sys/source/OSWin32.cpp @@ -26,7 +26,7 @@ #include #include -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include "sys/OSWin32.h" #include "sys/File.h" diff --git a/modules/c++/sys/source/Path.cpp b/modules/c++/sys/source/Path.cpp index 138956dc3..c46643854 100644 --- a/modules/c++/sys/source/Path.cpp +++ b/modules/c++/sys/source/Path.cpp @@ -177,7 +177,7 @@ std::string Path::absolutePath(const std::string& path) bool Path::isAbsolutePath(const std::string& path) { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 return !Path::splitDrive(path).first.empty(); #else return (!path.empty() && path[0] == Path::delimiter()[0]); @@ -232,7 +232,7 @@ std::string Path::basename(const std::string& path, bool removeExt) Path::StringPair Path::splitDrive(const std::string& path) { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 std::string::size_type pos = path.find(":"); #else std::string::size_type pos = std::string::npos; @@ -245,7 +245,7 @@ Path::StringPair Path::splitDrive(const std::string& path) const char* Path::delimiter() { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 return "\\"; #else return "/"; @@ -254,7 +254,7 @@ const char* Path::delimiter() const char* Path::separator() { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 return ";"; #else return ":"; diff --git a/modules/c++/sys/source/ProcessUnix.cpp b/modules/c++/sys/source/ProcessUnix.cpp index d31c20ae5..25acd6526 100644 --- a/modules/c++/sys/source/ProcessUnix.cpp +++ b/modules/c++/sys/source/ProcessUnix.cpp @@ -21,7 +21,7 @@ */ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include #include "sys/ProcessUnix.h" #include diff --git a/modules/c++/sys/source/ProcessWin32.cpp b/modules/c++/sys/source/ProcessWin32.cpp index 79145791b..52c57fa17 100644 --- a/modules/c++/sys/source/ProcessWin32.cpp +++ b/modules/c++/sys/source/ProcessWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include "sys/Process.h" #include "sys/Thread.h" diff --git a/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp b/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp index 1c88df2cc..f56e45e77 100644 --- a/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp +++ b/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp @@ -20,7 +20,7 @@ * */ -#if !(defined(WIN32) || defined(_WIN32)) +#ifndef _WIN32 #include diff --git a/modules/c++/sys/source/SemaphoreWin32.cpp b/modules/c++/sys/source/SemaphoreWin32.cpp index a4a555752..fcfd8255b 100644 --- a/modules/c++/sys/source/SemaphoreWin32.cpp +++ b/modules/c++/sys/source/SemaphoreWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) diff --git a/modules/c++/sys/source/ThreadPosix.cpp b/modules/c++/sys/source/ThreadPosix.cpp index 07f7f9867..4892ab396 100644 --- a/modules/c++/sys/source/ThreadPosix.cpp +++ b/modules/c++/sys/source/ThreadPosix.cpp @@ -24,7 +24,7 @@ #if CODA_OSS_POSIX_SOURCE -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 # define SIGKILL 0 #endif void sys::ThreadPosix::start() diff --git a/modules/c++/sys/source/ThreadWin32.cpp b/modules/c++/sys/source/ThreadWin32.cpp index 347e0b558..43ee313b6 100644 --- a/modules/c++/sys/source/ThreadWin32.cpp +++ b/modules/c++/sys/source/ThreadWin32.cpp @@ -21,7 +21,7 @@ */ -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(USE_NSPR_THREADS) #include "sys/ThreadWin32.h" diff --git a/modules/c++/unique/source/UUID.cpp b/modules/c++/unique/source/UUID.cpp index d0d409bd8..682dac843 100644 --- a/modules/c++/unique/source/UUID.cpp +++ b/modules/c++/unique/source/UUID.cpp @@ -22,7 +22,7 @@ #include "unique/UUID.hpp" -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #include #else #include @@ -30,7 +30,7 @@ std::string unique::generateUUID() { -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 GUID uuid; unsigned char *cResult = NULL; diff --git a/modules/c++/xml.lite/include/xml/lite/Attributes.h b/modules/c++/xml.lite/include/xml/lite/Attributes.h index 17c40e410..8b354844b 100644 --- a/modules/c++/xml.lite/include/xml/lite/Attributes.h +++ b/modules/c++/xml.lite/include/xml/lite/Attributes.h @@ -31,6 +31,7 @@ #include "except/Exception.h" #include "xml/lite/QName.h" #include "str/Convert.h" +#include "gsl/gsl.h" /*! * \file Attributes.h @@ -330,7 +331,7 @@ struct Attributes final } std::string operator[](const xml::lite::QName& name) const { - const size_t idx = getIndex(name); + const auto idx = gsl::narrow(getIndex(name)); return mAttributes[idx].getValue(); } @@ -348,7 +349,7 @@ struct Attributes final } std::string operator[](const std::string& s) const { - const size_t idx = getIndex(s); + const auto idx = gsl::narrow(getIndex(s)); return mAttributes[idx].getValue(); } diff --git a/modules/c++/xml.lite/source/ValidatorXerces.cpp b/modules/c++/xml.lite/source/ValidatorXerces.cpp index 013c47af4..7657e7b8a 100644 --- a/modules/c++/xml.lite/source/ValidatorXerces.cpp +++ b/modules/c++/xml.lite/source/ValidatorXerces.cpp @@ -179,8 +179,8 @@ ValidatorXerces::ValidatorXerces( // On Windows, this needs to be wchar_t so that various "wide character" Win32 APIs can be called. static_assert(sizeof(XMLCh) == 2, "XMLCh should be two bytes for UTF-16."); -#if _WIN32 -// On other platforms, char16_t/uint16_t is used; only wchar_t on Windows. +#ifdef _WIN32 +// On other platforms, char16_t is used; only wchar_t on Windows. using XMLCh_t = wchar_t; static_assert(std::is_same<::XMLCh, XMLCh_t>::value, "XMLCh should be wchar_t"); inline void reset(str::EncodedStringView xmlView, std::unique_ptr& pWString) @@ -196,10 +196,6 @@ inline void reset(str::EncodedStringView xmlView, std::unique_ptr(xmlView.u16string()); } -inline void reset(str::EncodedStringView xmlView, std::unique_ptr& pWString) -{ - pWString = std::make_unique(xmlView.ui16string_()); -} using XMLCh_string = std::basic_string; static std::unique_ptr setStringData(xercesc::DOMLSInputImpl& input, const std::u8string& xml)