msvc: tidy up _CRT_*_NO_DEPRECATE definitions
Dedupe and migrate MSVC-specific warning suppressions to `curl_setup.h`. Make cmake set `_CRT_SECURE_NO_DEPRECATE` for examples and standalone tests, and stop setting `_CRT_NONSTDC_NO_DEPRECATE` for them. Details: - drop version guards. On ancient MSVC version these macro are a no-op. - move to `curl_setup.h` from `config-win32*.h`. - sync macro values with CMake. - cmake: stop setting them globally in favour of `curl_setup.h`. - cmake: re-add these macros to `docs/examples` and `tests/http/clients`, which do not use `curl_setup.h`. - cmake: drop `_CRT_NONSTDC_NO_DEPRECATE` for examples and tests. They build fine without. - update comments. Closes #15960
This commit is contained in:
parent
c8d800a2f0
commit
de3e662ce1
@ -1892,7 +1892,6 @@ if(MSVC)
|
||||
# Disable default manifest added by CMake
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||
|
||||
add_definitions("-D_CRT_SECURE_NO_DEPRECATE" "-D_CRT_NONSTDC_NO_DEPRECATE")
|
||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
else()
|
||||
|
||||
@ -33,7 +33,7 @@ foreach(_target IN LISTS check_PROGRAMS)
|
||||
add_executable(${_target_name} EXCLUDE_FROM_ALL "${_target}.c")
|
||||
add_dependencies(curl-examples ${_target_name})
|
||||
target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_LIBS})
|
||||
target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES")
|
||||
target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES" "$<$<BOOL:MSVC>:_CRT_SECURE_NO_DEPRECATE>")
|
||||
if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
|
||||
@ -293,12 +293,6 @@
|
||||
#define HAVE_LONGLONG 1
|
||||
#endif
|
||||
|
||||
/* Define to avoid VS2005 complaining about portable C functions. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
/* mingw-w64 and visual studio >= 2005 (MSVCR80)
|
||||
all default to 64-bit time_t unless _USE_32BIT_TIME_T is defined */
|
||||
#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined(__MINGW32__)
|
||||
|
||||
@ -218,12 +218,6 @@
|
||||
/* Undef keyword 'const' if it does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to avoid VS2005 complaining about portable C functions. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
/* VS2005 and later default size for time_t is 64-bit, unless */
|
||||
/* _USE_32BIT_TIME_T has been defined to get a 32-bit time_t. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
|
||||
@ -85,13 +85,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disable Visual Studio warnings:
|
||||
* 4127 "conditional expression is constant"
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
/* Disable Visual Studio warnings: 4127 "conditional expression is constant" */
|
||||
#pragma warning(disable:4127)
|
||||
/* Avoid VS2005 and upper complaining about portable C functions. */
|
||||
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE /* for strdup(), write(), etc. */
|
||||
#endif
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE /* for fopen(), getenv(), etc. */
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
|
||||
@ -38,7 +38,7 @@ foreach(_target IN LISTS check_PROGRAMS)
|
||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
|
||||
)
|
||||
target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_LIBS})
|
||||
target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES")
|
||||
target_compile_definitions(${_target_name} PRIVATE "CURL_NO_OLDIES" "$<$<BOOL:MSVC>:_CRT_SECURE_NO_DEPRECATE>")
|
||||
if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user