Silence MSVC C4996 in specific cases
This commit is contained in:
parent
8707a13a2f
commit
0213eaf761
3 changed files with 30 additions and 0 deletions
|
@ -197,11 +197,21 @@ std::string os_version()
|
|||
|
||||
OSVERSIONINFOEX v { sizeof(OSVERSIONINFOEX) };
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// GetVersionEx is rather problematic, but it works for our usecase.
|
||||
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx
|
||||
// for more info.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
if(!GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&v))) {
|
||||
ERR_DU << "os_version: GetVersionEx error ("
|
||||
<< GetLastError() << ")\n";
|
||||
return base;
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
const DWORD vnum = v.dwMajorVersion * 100 + v.dwMinorVersion;
|
||||
std::string version;
|
||||
|
|
|
@ -134,7 +134,17 @@ void connection::cancel()
|
|||
{
|
||||
if(socket_.is_open()) {
|
||||
boost::system::error_code ec;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Silence warning about boost::asio::basic_socket<Protocol>::cancel always
|
||||
// returning an error on XP, which we don't support anymore.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
socket_.cancel(ec);
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
if(ec) {
|
||||
WRN_NW << "Failed to cancel network operations: " << ec.message() << std::endl;
|
||||
|
|
|
@ -187,7 +187,17 @@ void wesnothd_connection::cancel()
|
|||
MPTEST_LOG;
|
||||
if(socket_.is_open()) {
|
||||
boost::system::error_code ec;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Silence warning about boost::asio::basic_socket<Protocol>::cancel always
|
||||
// returning an error on XP, which we don't support anymore.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
socket_.cancel(ec);
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
if(ec) {
|
||||
WRN_NW << "Failed to cancel network operations: " << ec.message() << std::endl;
|
||||
|
|
Loading…
Add table
Reference in a new issue