Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Oct 21, 2025

  • curl_setup.h: replace _CRT_SECURE_NO_DEPRECATE with
    _CRT_SECURE_NO_WARNINGS, which seems to be the preferred,
    more recent macro for this. Also syncing with libssh2.
    They are equivalent for curl sources with the supported compilers.
  • cmake: stop setting _CRT_SECURE_NO_DEPRECATE globally for examples.
  • examples: suppress CRT deprecation warnings on a per-file basis.
    To make it work when compiling examples out of curl's build systems.
    Use _CRT_SECURE_NO_WARNINGS.
  • examples: document the functions requiring _CRT_SECURE_NO_WARNINGS.
  • examples/block_ip: delete superfluous _CRT_SECURE_NO_WARNINGS.
  • examples/block_ip: limit _CRT_NONSTDC_NO_DEPRECATE to MSVC.
  • examples/log_failed_transfers: fix to set _CRT_SECURE_NO_WARNINGS
    before headers and limit to MSVC.
  • curl_setup.h: document which SDKs support _CRT_NONSTDC_NO_DEPRECATE.

@vszakats vszakats marked this pull request as draft October 21, 2025 09:51
@vszakats vszakats changed the title test msvc warning suppression option 1 [TEST] test msvc warning suppression option 1 Oct 21, 2025
@vszakats vszakats changed the title [TEST] test msvc warning suppression option 1 examples: drop _CRT_SECURE_NO_WARNINGS Oct 21, 2025
@vszakats vszakats changed the title examples: drop _CRT_SECURE_NO_WARNINGS [TEST] test msvc warning suppression option 1 Oct 21, 2025
@jay
Copy link
Member

jay commented Oct 21, 2025

Just a reminder that the way MS treats "deprecated" is not the way others do because those functions aren't removed. Also like fopen is "insecure", they're never going to get rid of it, all these C functions that they mark as insecure or deprecated because they don't do exactly what MS wants

@vszakats
Copy link
Member Author

vszakats commented Oct 21, 2025

@jay I'm aware, yes. Just trying to map it out what exactly are they suppressing,
figuring out if _CRT_SECURE_NO_DEPRECATE or _CRT_SECURE_NO_WARNINGS
is the "best" (I've made a rounds with this in the past, but it's again a bit inconsistent
between libssh2 and parts of curl), and perhaps review how they are suppressed in
examples (per-source would be more user-friendly, but perhaps not practical if many
of them need the defines).

One thing I found is that the warning messages agree on suggesting _CRT_SECURE_NO_WARNINGS.

@vszakats vszakats marked this pull request as ready for review November 17, 2025 21:46
@vszakats vszakats changed the title [TEST] test msvc warning suppression option 1 windows: tidy-up CRT warning suppression macros Nov 17, 2025
@vszakats vszakats added build Windows Windows-specific labels Nov 17, 2025
@vszakats vszakats changed the title windows: tidy-up CRT warning suppression macros build: tidy-up Windows CRT warning suppression macros Nov 17, 2025
@vszakats vszakats marked this pull request as draft November 17, 2025 21:54
@vszakats
Copy link
Member Author

_CRT_SECURE_NO_WARNINGS warnings made visible: https://github.com/curl/curl/actions/runs/19446115443/job/55640968722
_CRT_NONSTDC_NO_DEPRECATE fallouts (partial, for lib): https://github.com/curl/curl/actions/runs/19446535634/job/55642317260?pr=19175

@vszakats vszakats marked this pull request as ready for review November 17, 2025 23:13
@vszakats vszakats changed the title build: tidy-up Windows CRT warning suppression macros build: tidy-up MSVC CRT warning suppression macros Nov 17, 2025
@vszakats
Copy link
Member Author

Ended up going with _CRT_SECURE_NO_WARNINGS, which is the one
settled on at libssh2, and seems to be the more recent macro to use.
I documented most fallouts these macros are silencing, and moved
definitions to each example that needs it, from the CMakeLists.txt.
Also fixed some tiny nits found along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants