approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
312 stars 51 forks source link

Starter Project for v.10.2.0 release fails to build on Visual Studio with C4996 for use of gmtime() #150

Closed claremacrae closed 3 years ago

claremacrae commented 3 years ago

The error is:

d:\a\ApprovalTests.cpp.StarterProject\ApprovalTests.cpp.StarterProject\lib\ApprovalTests.v.10.2.0.hpp(4825,18): error C4996: 'gmtime': This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [d:\a\ApprovalTests.cpp.StarterProject\ApprovalTests.cpp.StarterProject\visual-studio-2019\StarterProject2019.vcxproj]

0 Warning(s)
1 Error(s)

What I don't understand is that only gives a warning, and not an error, when building the main ApprovalTests project on Visual Studio, where I also expected warnings to be treated as errors - but DateUtils.cpp only generates a warning for C4996

Example failed build: https://github.com/approvals/ApprovalTests.cpp.StarterProject/runs/950564893?check_suite_focus=true#step:9:14

claremacrae commented 3 years ago

What I don't understand is that only gives a warning, and not an error, when building the main ApprovalTests project on Visual Studio

Since I moved the implementations of approval test headers to .cpp projects, the .cpp files are compiled by ApprovalTests/CMakeLists.txt - which does not contain this line:

include(WarningsAsErrors)
claremacrae commented 3 years ago

This is fixed in 10.2.1