Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Windows_h_proxy is included in catch_all.hpp and does name-polution

Open dimztimz opened this issue 3 years ago • 1 comments

Describe the bug If I include catch2/catch_all.hpp on Windows it transitively includes windows.h which defines a lot of preprocessor definitions whose names will be in conflict with my code.

Expected behavior Windows.h should be included only in the implementation files of catch2, not in the public headers.

Reproduction steps See description above.

Platform information:

  • OS: Windows NT
  • Compiler+version: GCC 11 (Mingw64)
  • Catch version: v3.0.1

dimztimz avatar May 20 '22 09:05 dimztimz

Do you know how to fix this? I expected this to be an easy fix, remove just a line from catch_all.hpp, but this came up https://github.com/catchorg/Catch2/blob/devel/tools/scripts/checkConvenienceHeaders.py and makes the test-suite fail.

Maybe a better fix is to include windows.h directly where needed and completely delete this file catch_windows_h_proxy.hpp. An even better solution is to have public and private headers, install only the public headers and any scripts like the above one should test only for those. I'd go with the former solution right now.

dimztimz avatar Jun 10 '22 20:06 dimztimz