Catch2: Cannot compile for UWP (Universal Windows Platform)
Description
I am porting an existing project that makes use of Catch to UWP. When compiling I get the following errors (amongst others):
error C3861: 'AddVectoredExceptionHandler': identifier not found
error C3861: 'SetThreadStackGuarantee': identifier not found
error C3861: 'RemoveVectoredExceptionHandler': identifier not found
error C3861: 'SetThreadStackGuarantee': identifier not found
error C3861: 'GetStdHandle': identifier not found
error C2065: 'CONSOLE_SCREEN_BUFFER_INFO': undeclared identifier
It would seem that UWP does not supply these classes.
Steps to reproduce
- Using VS2017 create a new UWP App File -> New Project -> Installed -> Visual C++ -> Windows Universal ->DirectX 11 App (Universal Windows)
- Add catch.hpp to the project
- Include the header
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
- Compile
Extra information
- Catch version: v1.9.6 also tried v2.0.0-develop.3
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (15 by maintainers)
Commits related to this issue
- Do not use SEH and console api under UWP Fixes #1020 — committed to catchorg/Catch2 by horenmar 7 years ago
- Workaround for stitching issue in #1020 Closes #1020 — committed to catchorg/Catch2 by horenmar 7 years ago
@michaelcowan You could argue that the inconsistency stems from inconsistent behaviour between XCode and Visual Studio. By default, Catch writes its output to stdout. UWP apps do not show stdout anywhere, but it can be redirected by
freopen
and the like. It just so happens that XCode redirects stdout to its debug output on its own, while VS doesn’t.However, as you found out, you can ask Catch to redirect the output to a file (including a special file,
%debug
). Under everything that is not Visual Studio, the%debug
file just writes to stdout. For Visual Studio, we useOutputDebugStringA
, which does place the output to its debug output.This should be fixed in Catch 2