build: Bump MSVC warning level up to W3 #1328

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:230524-w3 changing 2 files +11 −2
  1. hebasto commented at 4:06 PM on May 24, 2023: member

    Solves one item in #1235.

  2. in src/CMakeLists.txt:82 in cfbec63ca8 outdated
      74 | @@ -75,31 +75,37 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
      75 |  endif()
      76 |  unset(${PROJECT_NAME}_soversion)
      77 |  
      78 | +add_library(secp256k1_warning_suppression INTERFACE)
      79 | +target_compile_options(secp256k1_warning_suppression INTERFACE
      80 | +  # Disable warning C4996 for the usage of a function, class member, variable, or typedef that's marked deprecated.
      81 | +  $<$<C_COMPILER_ID:MSVC>:/wd4996>
      82 | +)
    


    real-or-random commented at 7:32 AM on May 25, 2023:

    Why treat this special and not add it using try_append_c_flags?


    hebasto commented at 7:35 AM on May 25, 2023:

    Isn't it better to catch such warnings in non-test/bench code?


    real-or-random commented at 8:06 AM on May 25, 2023:

    I'm not convinced that this justifies making things more complicated in the build system.

    Hm, I just checked. The deprecated warnings here are all the same kind:

    src/tests.c(7695,27): warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    

    And we really don't want these warnings. We can't use _dupenv_s because it exists only on Windows. We can't use getenv_s because it requires C11 Annex K. But can we just pass /D_CRT_SECURE_NO_WARNINGS instead of /wd4996? That's narrower, and then I think there's really no need to restrict it to test/bench/etc.


    hebasto commented at 8:56 AM on May 25, 2023:

    Thanks! Updated.

  3. real-or-random commented at 7:32 AM on May 25, 2023: contributor

    Concept ACK

  4. build: Level up MSVC warnings 1549db0ca5
  5. hebasto force-pushed on May 25, 2023
  6. hebasto commented at 8:55 AM on May 25, 2023: member
  7. real-or-random approved
  8. real-or-random commented at 9:40 AM on May 25, 2023: contributor

    ACK 1549db0ca5193b8ba5d8f7478d54af2ca4b36c7e

    Do you believe it's worth making the - vs / style of passing options consistent? I prefer dashes slightly, but that's just my taste. It doesn't matter at all in the end. Maybe if CMake internally uses / (e.g., in add_compile_definitions), we should just switch to that one.

  9. hebasto commented at 9:53 AM on May 25, 2023: member

    ... if CMake internally uses / ...

    It does.

    Do you believe it's worth making the - vs / style of passing options consistent?

    Consistency within a particular build system does matter. Not sure about "cross build systems" consistency although.

  10. sipa commented at 11:53 AM on May 26, 2023: contributor

    utACK 1549db0ca5193b8ba5d8f7478d54af2ca4b36c7e

  11. real-or-random merged this on May 26, 2023
  12. real-or-random closed this on May 26, 2023

  13. hebasto deleted the branch on May 26, 2023
  14. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  15. sipa referenced this in commit 901336eee7 on Jun 21, 2023
  16. vmta referenced this in commit 8f03457eed on Jul 1, 2023
  17. hebasto referenced this in commit 270d2b37b8 on Jul 21, 2023
  18. delta1 referenced this in commit 3f32c20932 on Aug 8, 2023
  19. delta1 referenced this in commit 31ac0c1081 on Aug 31, 2023
  20. janus referenced this in commit c4348d88db on Sep 11, 2023
  21. div72 referenced this in commit af627d47c3 on Apr 12, 2025
  22. str4d referenced this in commit 5a6bf5f178 on Jun 4, 2025
  23. Fabcien referenced this in commit 7dc1a63a14 on Mar 3, 2026
  24. Fabcien referenced this in commit 8fbbc9174c on Mar 3, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC