Skip to content

Compilation fails on Windows with MinGW-32 GCC 5.3.0. #805

@nyamatongwe

Description

@nyamatongwe

Description

The headers for MinGW-32 GCC 5.3.0. do not include gmtime_s or SetThreadStackGuarantee and there
is no way to turn off the sections of Catch that use these.

gmtime_s is in Annex K of the C11 standard which is optional so gmtime_s is not portable. I think that gmtime should be used instead of gmtime_s. This may require a #define to avoid compiler warnings from MSVC.
SetThreadStackGuarantee is a Win32 API so should be available in any Windows compiler but unfortunately isn't with this compiler. Other related functions like AddVectoredExceptionHandler weren't available in the previous 4.9.0 release of MinGW-32. When working with Win32 Structured Exception Handling, its fine to require a working, current version of the Windows headers and libraries. However, SEH is not important in many cases so turning off its use should be an option.

Steps to reproduce

Here is a minimal Catch file:

// Minimal catch test
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"

With MinGW-32 GCC 5.3.0, show the version and compile the file:

>g++ --version && g++ --std=c++11 -Wall -Wextra minimal.cxx -o minimal.exe
g++ (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In file included from minimal.cxx:3:0:
catch.hpp: In constructor 'Catch::FatalConditionHandler::FatalConditionHandler()':
catch.hpp:6160:53: error: 'SetThreadStackGuarantee' was not declared in this scope
             SetThreadStackGuarantee(&m_guaranteeSize);
                                                     ^
catch.hpp: In member function 'void Catch::FatalConditionHandler::reset()':
catch.hpp:6167:57: error: 'SetThreadStackGuarantee' was not declared in this scope
                 SetThreadStackGuarantee(&m_guaranteeSize);
                                                         ^
In file included from minimal.cxx:3:0:
catch.hpp: In function 'std::__cxx11::string Catch::{anonymous}::getCurrentTimestamp()':
catch.hpp:9809:41: error: 'gmtime_s' was not declared in this scope
             gmtime_s(&timeInfo, &rawtime);
                                         ^

Extra information

  • Catch version: v1.7.0
  • Operating System: Microsoft Windows 10 Home 64-bit
  • Compiler+version: MinGW-32 GCC 5.3.0 from mingw.org

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions