-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Quick way to *only* include the implementation #1061
Comments
I'm not entirely sure what you're asking. But with precompiled headers you would only want the non-impl parts included (ie without Perhaps you could sketch in a little more? |
The case is, that I want to include |
Sorry, I didn't notice this before posting, but I have exactly the same problem. Maybe my description of it on the mailing list is more clear? |
@vadz It is clear enough, but not supported yet. As an ad-hoc solution, you can cut out everything guarded with |
FWIW I ended up doing
in the PCH-generating file. Ugly but seems to work. |
When I faced this issue, I made my main source file as small as possible, included only catch.hpp and turned off pre-compiled headers for that file. (Still annoying, but it worked.) |
I thought about this for a bit and I am going to implement it with some caveats
|
I made a proof of concept branch for this (dev-PCH-support) and it seems to work on a small scale, but I don't have any project handy to test it out on. // stdafx.h
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#define CATCH_CONFIG_ALL_PARTS
#include "catch.hpp" // PCH-test.cpp:
#include "stdafx.h"
#undef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define CATCH_CONFIG_IMPL_ONLY
#define CATCH_CONFIG_MAIN
#include "catch.hpp" // tests1.cpp:
#include "stdafx.h"
TEST_CASE("FooBarBaz") {
REQUIRE(1 == 2);
} Can someone test the attached single header version and report back? |
Works for me! |
It seems to work for me too, I just had to replace I'm still (and will continue to have to, in near future) using Catch 1.x though, I wonder if it could be backported there? Thanks! |
@vadz I won't be backporting it, but I'd expect one should be able to do it with relative ease by looking at the commit diff. |
v2.1.0 is out and contains the PCH support |
Consider the following case: I have a project, which is compiled using a precompiled header, in which I include
catch.hpp
, how would I now create Catch'smain
function (or pull in the required code to be compiled into my TU)?A quick'n'dirty way would be to add a macro, just like
CATCH_CONFIG_RUNNER
, which will only pull in the implementation and nothing else.The text was updated successfully, but these errors were encountered: