- project contortions to make MSVC print our own deprecations but silence the ones from the compiler.

Since everything uses the same warning number, the old setup resulted in [[deprecated]] being silenced.
So this explicitly adds the needed #defines to silence the very noisy warning from the MSVC headers but leaves warning 4996 active otherwise.

In particlular this does:

* silence all warnings in the subprojects
* do not derive TIterator from std::iterator anymore as C++17 deprecates this.
* silence the above for RapidJSON because altering that code is not desirable.
* explicitly disable warning 4996 in some Windows files that call the deprecated (but still needed) GetVersionEx function.
* define _CRT_SECURE_NO_DEPRECATE, _CRT_SECURE_NO_WARNINGS and _CRT_NONSTDC_NO_WARNINGS through CMake to disable the CRT's deprecation and security warnings.

Currently this will print several (intended) deprecation warnings about 'updatesector' that point to code that needs to be changed but cannot yet without other refactorings being done first.
This commit is contained in:
Christoph Oelckers 2021-11-06 16:48:31 +01:00
parent 83fe41e71e
commit 19363ac23e
11 changed files with 29 additions and 10 deletions

View file

@ -236,7 +236,7 @@ if( MSVC )
set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" )
# Disable warnings for unsecure CRT functions from VC8+
set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS" )
set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS" )
# These must be silenced because the code is full of them. Expect some of undefined behavior hidden in this mess. :(
#set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4244 /wd4018 /wd4267" )

View file

@ -2,6 +2,10 @@ cmake_minimum_required( VERSION 3.1.0 )
make_release_only()
if (MSVC)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244" )
endif()
add_definitions( -DBZ_NO_STDIO )
add_library( bz2 STATIC
blocksort.c

View file

@ -21,6 +21,10 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
endif()
if (MSVC)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4146" )
endif()
# Request C++11
if(${CMAKE_VERSION} VERSION_LESS 3.1)
# CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD

View file

@ -6,6 +6,10 @@ if( DEM_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
endif()
if (MSVC)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267" )
endif()
add_library( jpeg STATIC
jaricom.c
jcomapi.c

View file

@ -111,9 +111,9 @@ void I_InitGraphics ()
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
currentgpuswitch = vid_gpuswitch;
if (currentgpuswitch == 1)
putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
_putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
else if (currentgpuswitch == 2)
putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
_putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
// If the focus window is destroyed, it doesn't go back to the active window.
// (e.g. because the net pane was up, and a button on it had focus)

View file

@ -34,6 +34,7 @@
// HEADER FILES ------------------------------------------------------------
#pragma warning(disable:4996)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <richedit.h>

View file

@ -45,6 +45,7 @@
// HEADER FILES ------------------------------------------------------------
#pragma warning(disable:4996)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View file

@ -29,6 +29,7 @@ RAPIDJSON_DIAG_PUSH
#ifdef _MSC_VER
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data
RAPIDJSON_DIAG_OFF(4996) // deprecation of std::iterator
#endif
#ifdef __clang__

View file

@ -63,14 +63,14 @@
#include "m_alloc.h"
template<typename T> class TIterator : public std::iterator<std::random_access_iterator_tag, T>
template<typename T> class TIterator
{
public:
typedef typename TIterator::value_type value_type;
typedef typename TIterator::difference_type difference_type;
typedef typename TIterator::pointer pointer;
typedef typename TIterator::reference reference;
typedef typename TIterator::iterator_category iterator_category;
typedef typename T value_type;
typedef typename ptrdiff_t difference_type;
typedef typename T* pointer;
typedef typename T& reference;
typedef typename std::random_access_iterator_tag iterator_category;
TIterator(T* ptr = nullptr) { m_ptr = ptr; }

View file

@ -3,6 +3,10 @@ cmake_minimum_required( VERSION 3.1.0 )
if( NOT CMAKE_CROSSCOMPILING )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG" )
if (MSVC)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4267" )
endif()
add_executable( lemon lemon.c )
set( CROSS_EXPORTS ${CROSS_EXPORTS} lemon PARENT_SCOPE )

View file

@ -7,7 +7,7 @@ include( CheckTypeSize )
if( MSVC )
# Runtime type information is required and don't complain about uint32_t to bool conversions
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /wd4800" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /wd4800 /wd4244" )
endif()
set( PACKAGE_NAME re2c )