trompeloeil
trompeloeil copied to clipboard
catch2/trompeloeil.hpp header requires bigger Catch2 include than is actually needed
Catch2 v3 is no longer distributed as a single header. If you do this:
#include <catch2/catch_test_macros.hpp>
#include <catch2/trompeloeil.hpp>
Then the CATCH_VERSION_MAJOR will not be set, used here:
https://github.com/rollbear/trompeloeil/blob/6b2742870a4b08e87cf104e2e9e7904c3818275d/include/catch2/trompeloeil.hpp#L19
since that's in #include <catch2/catch_version_macros.hpp>. While this is included in Catch2's catch2/catch_all.hpp, the new split Catch2 headers apparently allow much faster compilation.
catch2/trompeloeil.hpp only actually needs the macros from catch_test_macros.hpp (specifically FAIL, CAPTURE, CHECK and REQUIRE).
It would be better, I think, if the check actually checked for what was used, perhaps like:
#if ! (defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CHECK)) || (!defined(CATCH_CONFIG_PREFIX_ALL) && defined(CHECK))
#error "Catch2 macros must be defined before including <catch2/trompeloeil.hpp>"
#endif
(or it could do the include itself?)
Thanks. I'll look into it.
Corrected fix:
#if !((defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CHECK)) || (!defined(CATCH_CONFIG_PREFIX_ALL) && defined(CHECK)))
#error "Catch2 macros must be defined before including <catch2/trompeloeil.hpp>"
#endif
Was missing parentheses.