HomePhabricator

Misuse of the Visual Studio version preprocessor macro

Description

Misuse of the Visual Studio version preprocessor macro

Summary:
The gmtime_s function (used in src/util/time.cpp) is a Microsoft C
runtime (CRT) function (arguments are reversed wrt C11).

There is a preprocessor switch to only use this function with Visual
Studio, but this is inaccurate. This should be used with all the
compilers that use the CRT, including MinGw (but not Cygwin for
example). The correct preprocessor macro for this is _WIN32.

Note: MinGw used to define _MSC_VER under certain circumstances, but
it should not be relied upon (see discussion from
https://sourceforge.net/p/mingw-w64/bugs/282/). This definition appears
to be dependent on headers ordering (D5445 will break the Windows build
as is, but won't if chrono is included last). As a consequence it also
fixes the build with recent versions of MinGw (building on Debian
testing was broken).

Test Plan:
Run the Gitian builds.
Build for windows on Debian testing.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5448

Details

Provenance
FabienAuthored on Mar 9 2020, 08:44
FabienPushed on Mar 10 2020, 07:36
Reviewer
Restricted Project
Differential Revision
D5448: Misuse of the Visual Studio version preprocessor macro
Parents
rABC170ea4fe02a7: [CMAKE] Silent git error output when running from cmake
Branches
Unknown
Tags
Unknown