From 22eb76d3ae36c62e031d49feb06dcaa5a9e05664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Thu, 17 Jun 2021 18:20:29 +0200 Subject: [PATCH] #3302: MSVC: Poco hides warnings (C4996) for the C++14 attribute [[deprecated]] --- Crypto/include/Poco/Crypto/EVPPKey.h | 8 ++++++++ Crypto/src/PKCS12Container.cpp | 5 +++++ Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h | 7 +++++++ Foundation/include/Poco/Platform_WIN32.h | 5 ----- Foundation/src/Environment.cpp | 5 +++++ Foundation/src/Environment_WIN32U.cpp | 5 +++++ Foundation/src/FPEnvironment.cpp | 5 +++++ Foundation/src/LocalDateTime.cpp | 5 +++++ Foundation/src/NumberFormatter.cpp | 6 ++++++ Foundation/src/Timezone.cpp | 5 +++++ Foundation/testsuite/src/DateTimeTest.cpp | 5 +++++ Foundation/testsuite/src/LocalDateTimeTest.cpp | 6 ++++++ Foundation/testsuite/src/StringTest.cpp | 5 +++++ Net/src/IPAddressImpl.cpp | 5 +++++ Net/src/NetworkInterface.cpp | 5 +++++ Net/src/SocketImpl.cpp | 5 +++++ NetSSL_OpenSSL/src/SSLManager.cpp | 6 ++++++ NetSSL_Win/src/SSLManager.cpp | 5 +++++ Redis/src/RedisStream.cpp | 4 ++-- Util/src/SystemConfiguration.cpp | 5 +++++ XML/src/xmlparse.cpp | 4 ++++ 21 files changed, 104 insertions(+), 7 deletions(-) diff --git a/Crypto/include/Poco/Crypto/EVPPKey.h b/Crypto/include/Poco/Crypto/EVPPKey.h index 87ab962d4..7cf44d867 100644 --- a/Crypto/include/Poco/Crypto/EVPPKey.h +++ b/Crypto/include/Poco/Crypto/EVPPKey.h @@ -177,7 +177,15 @@ private: EVP_PKEY* pKey = getFunc ? EVP_PKEY_new() : (EVP_PKEY*)*ppKey; if (pKey) { +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // deprecation warnings +#endif pFile = fopen(keyFile.c_str(), "r"); +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + if (pFile) { pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB; diff --git a/Crypto/src/PKCS12Container.cpp b/Crypto/src/PKCS12Container.cpp index 39dc3f09c..dfc411130 100644 --- a/Crypto/src/PKCS12Container.cpp +++ b/Crypto/src/PKCS12Container.cpp @@ -13,6 +13,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/Crypto/PKCS12Container.h" #include "Poco/NumberFormatter.h" #include "Poco/StreamCopier.h" diff --git a/Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h b/Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h index fa1abe945..2cd237b94 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h +++ b/Data/ODBC/include/Poco/Data/ODBC/Unicode_WIN32.h @@ -47,7 +47,14 @@ inline void makeUTF8(Poco::Buffer& buffer, SQLINTEGER length, SQLPOINTE UnicodeConverter::toUTF8(buffer.begin(), length, result); std::memset(pTarget, 0, targetLength); +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // deprecation warnings +#endif std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength); +#if defined(_MSC_VER) +#pragma warning(pop) +#endif } diff --git a/Foundation/include/Poco/Platform_WIN32.h b/Foundation/include/Poco/Platform_WIN32.h index 77e448fca..65cdf46f5 100644 --- a/Foundation/include/Poco/Platform_WIN32.h +++ b/Foundation/include/Poco/Platform_WIN32.h @@ -22,10 +22,6 @@ #include "Poco/UnWindows.h" -#if defined(_MSC_VER) && !defined(POCO_MSVC_SECURE_WARNINGS) && !defined(_CRT_SECURE_NO_DEPRECATE) - #define _CRT_SECURE_NO_DEPRECATE -#endif - // Verify that we're built with the multithreaded // versions of the runtime libraries @@ -78,7 +74,6 @@ #pragma warning(disable:4351) // new behavior: elements of array '...' will be default initialized #pragma warning(disable:4355) // 'this' : used in base member initializer list #pragma warning(disable:4675) // resolved overload was found by argument-dependent lookup - #pragma warning(disable:4996) // VC++ 8.0 deprecation warnings #endif diff --git a/Foundation/src/Environment.cpp b/Foundation/src/Environment.cpp index e81a8a7c1..58a8ef3d5 100644 --- a/Foundation/src/Environment.cpp +++ b/Foundation/src/Environment.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/Environment.h" #include "Poco/Version.h" #include diff --git a/Foundation/src/Environment_WIN32U.cpp b/Foundation/src/Environment_WIN32U.cpp index 624ff83c8..3ba854981 100644 --- a/Foundation/src/Environment_WIN32U.cpp +++ b/Foundation/src/Environment_WIN32U.cpp @@ -25,6 +25,11 @@ #include +#if defined(_MSC_VER) +#pragma warning(disable:4996) // deprecation warnings +#endif + + namespace Poco { diff --git a/Foundation/src/FPEnvironment.cpp b/Foundation/src/FPEnvironment.cpp index 4617b7841..3b853ddc6 100644 --- a/Foundation/src/FPEnvironment.cpp +++ b/Foundation/src/FPEnvironment.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + // pull in platform identification macros needed below #include "Poco/Platform.h" #include "Poco/FPEnvironment.h" diff --git a/Foundation/src/LocalDateTime.cpp b/Foundation/src/LocalDateTime.cpp index 6683f8012..bdd0ca0bf 100644 --- a/Foundation/src/LocalDateTime.cpp +++ b/Foundation/src/LocalDateTime.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/LocalDateTime.h" #include "Poco/Timezone.h" #include "Poco/Timespan.h" diff --git a/Foundation/src/NumberFormatter.cpp b/Foundation/src/NumberFormatter.cpp index 43178b1ae..663864215 100644 --- a/Foundation/src/NumberFormatter.cpp +++ b/Foundation/src/NumberFormatter.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/NumberFormatter.h" #include "Poco/MemoryStream.h" #include @@ -31,6 +36,7 @@ #endif + namespace Poco { diff --git a/Foundation/src/Timezone.cpp b/Foundation/src/Timezone.cpp index fa229cbb2..a70a0cfe8 100644 --- a/Foundation/src/Timezone.cpp +++ b/Foundation/src/Timezone.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/Timezone.h" #include diff --git a/Foundation/testsuite/src/DateTimeTest.cpp b/Foundation/testsuite/src/DateTimeTest.cpp index 4b946bdd6..1f8cccf9e 100644 --- a/Foundation/testsuite/src/DateTimeTest.cpp +++ b/Foundation/testsuite/src/DateTimeTest.cpp @@ -8,6 +8,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "DateTimeTest.h" #include "CppUnit/TestCaller.h" #include "CppUnit/TestSuite.h" diff --git a/Foundation/testsuite/src/LocalDateTimeTest.cpp b/Foundation/testsuite/src/LocalDateTimeTest.cpp index 5cf89c294..f0a5ad579 100644 --- a/Foundation/testsuite/src/LocalDateTimeTest.cpp +++ b/Foundation/testsuite/src/LocalDateTimeTest.cpp @@ -8,6 +8,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "LocalDateTimeTest.h" #include "CppUnit/TestCaller.h" #include "CppUnit/TestSuite.h" @@ -24,6 +29,7 @@ #include "wce_time.h" #endif + using Poco::LocalDateTime; using Poco::DateTime; using Poco::Timestamp; diff --git a/Foundation/testsuite/src/StringTest.cpp b/Foundation/testsuite/src/StringTest.cpp index 860445069..976ec484e 100644 --- a/Foundation/testsuite/src/StringTest.cpp +++ b/Foundation/testsuite/src/StringTest.cpp @@ -8,6 +8,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "StringTest.h" #include "CppUnit/TestCaller.h" #include "CppUnit/TestSuite.h" diff --git a/Net/src/IPAddressImpl.cpp b/Net/src/IPAddressImpl.cpp index dcc63e686..4b20b1dbb 100644 --- a/Net/src/IPAddressImpl.cpp +++ b/Net/src/IPAddressImpl.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_WINSOCK_DEPRECATED_NO_WARNINGS) +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif + + #include "Poco/Net/IPAddressImpl.h" #include "Poco/Net/NetException.h" #include "Poco/RefCountedObject.h" diff --git a/Net/src/NetworkInterface.cpp b/Net/src/NetworkInterface.cpp index b59e53032..6fcd0eb25 100644 --- a/Net/src/NetworkInterface.cpp +++ b/Net/src/NetworkInterface.cpp @@ -38,6 +38,11 @@ #include +#if defined(_MSC_VER) +#pragma warning(disable:4996) // deprecation warnings +#endif + + using Poco::NumberFormatter; using Poco::FastMutex; using Poco::format; diff --git a/Net/src/SocketImpl.cpp b/Net/src/SocketImpl.cpp index 4fc40f16a..000de2dd5 100644 --- a/Net/src/SocketImpl.cpp +++ b/Net/src/SocketImpl.cpp @@ -51,6 +51,11 @@ #endif +#if defined(_MSC_VER) +#pragma warning(disable:4996) // deprecation warnings +#endif + + using Poco::IOException; using Poco::TimeoutException; using Poco::InvalidArgumentException; diff --git a/NetSSL_OpenSSL/src/SSLManager.cpp b/NetSSL_OpenSSL/src/SSLManager.cpp index f469adb69..efceb4dc0 100644 --- a/NetSSL_OpenSSL/src/SSLManager.cpp +++ b/NetSSL_OpenSSL/src/SSLManager.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) +#pragma warning(disable:4996) // deprecation warnings +#endif + + #include "Poco/Net/SSLManager.h" #include "Poco/Net/Context.h" #include "Poco/Net/Utility.h" @@ -26,6 +31,7 @@ #include "Poco/Util/OptionException.h" + namespace Poco { namespace Net { diff --git a/NetSSL_Win/src/SSLManager.cpp b/NetSSL_Win/src/SSLManager.cpp index fbabfcb03..75827bac0 100644 --- a/NetSSL_Win/src/SSLManager.cpp +++ b/NetSSL_Win/src/SSLManager.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) +#pragma warning(disable:4996) // deprecation warnings +#endif + + #include "Poco/Net/SSLManager.h" #include "Poco/Net/Context.h" #include "Poco/Net/Utility.h" diff --git a/Redis/src/RedisStream.cpp b/Redis/src/RedisStream.cpp index a81eb2939..1a8a507f4 100644 --- a/Redis/src/RedisStream.cpp +++ b/Redis/src/RedisStream.cpp @@ -41,13 +41,13 @@ RedisStreamBuf::~RedisStreamBuf() int RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len) { - return _redis.receiveBytes(buffer, len); + return _redis.receiveBytes(buffer, static_cast(len)); } int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { - return _redis.sendBytes(buffer, length); + return _redis.sendBytes(buffer, static_cast(length)); } diff --git a/Util/src/SystemConfiguration.cpp b/Util/src/SystemConfiguration.cpp index 19332f14c..352eb5437 100644 --- a/Util/src/SystemConfiguration.cpp +++ b/Util/src/SystemConfiguration.cpp @@ -12,6 +12,11 @@ // +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + + #include "Poco/Util/SystemConfiguration.h" #include "Poco/Environment.h" #include "Poco/Path.h" diff --git a/XML/src/xmlparse.cpp b/XML/src/xmlparse.cpp index 4d6afb5cd..e55e9b9e6 100644 --- a/XML/src/xmlparse.cpp +++ b/XML/src/xmlparse.cpp @@ -65,6 +65,10 @@ # endif #endif +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + #include #include /* memset(), memcpy() */ #include