Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro redefinition when compiling on windows with clang #2307

Closed
robojan opened this issue Oct 17, 2021 · 1 comment
Closed

Macro redefinition when compiling on windows with clang #2307

robojan opened this issue Oct 17, 2021 · 1 comment

Comments

@robojan
Copy link

robojan commented Oct 17, 2021

Describe the bug
When building catch 2 on windows with clang both the Microsoft visual studio and clang compilers are detected in catch_compiler_capabilities.hpp which results in the following macros being redefined:

  • CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
  • CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION

The following warnings are generated:

E:/git/robojan/fatpp/build/_deps/catch2-src/src/catch2/..\catch2/internal/catch_compiler_capabilities.hpp:157:11: warning: 'CATCH_INTERNAL_START_WARNINGS_SUPPRESSION' macro redefined [-Wmacro-redefined]
#  define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) )
          ^
E:/git/robojan/fatpp/build/_deps/catch2-src/src/catch2/..\catch2/internal/catch_compiler_capabilities.hpp:62:13: note: previous definition is here
#    define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
            ^
E:/git/robojan/fatpp/build/_deps/catch2-src/src/catch2/..\catch2/internal/catch_compiler_capabilities.hpp:158:11: warning: 'CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION' macro redefined [-Wmacro-redefined]
#  define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  __pragma( warning(pop) )
          ^
E:/git/robojan/fatpp/build/_deps/catch2-src/src/catch2/..\catch2/internal/catch_compiler_capabilities.hpp:63:13: note: previous definition is here
#    define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  _Pragma( "clang diagnostic pop" )

Expected behavior
I would expect that no warnings are generated, and the correct compiler was detected.

Reproduction steps
Compile a file which includes catch2/catch_test_macros.hpp with clang 13 on windows

Platform information:

  • OS: Windows NT x86_64-pc-windows-msvc
  • Compiler+version: Clang 13.0.0
  • Catch version: v3.0.0-preview3

Additional context
It may be possible to extend the check for MSVC to
#if defined(_MSC_VER) && !defined(__clang__)
from
#if defined(_MSC_VER)

But it seems that clang masquerading is already handled in the MSVC case. So there may be some implications of this change that i don't see.

@horenmar
Copy link
Member

Turns out this is already fixed in devel, by only enabling the clang-specific pragmas if _MSC_VER is not also enabled (in which case we assume that Clang handles __pragmas and let it handle the MSVC macros).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants