-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Compile errors with iosfwd.h and Visual Studio 2019 Preview #183
Comments
Hi! I'll try to get to this when I can, but for now I'd recommend including whatever STL headers are necessary to make things compile. Thanks for reporting! |
Thanks @onqtam , that is indeed the route I have currently picked (just adding extra |
But on the top of my head - actually
as seen here: https://en.cppreference.com/w/cpp/header/string So I'm a bit clueless as to why this could have happened. But anyway I'll try VS 2019 when I get the chance. |
So I played a bit with VS 2019 and turns out this is an STL bug. The user should be able to do the following: #include <string>
#include <iosfwd>
void foo(std::ostream& s) {
s << std::string("");
} But with VS 2019 that is no longer possible. This is valid code since There is nothing I'm willing to do on the side of doctest because there are only 2 options: either disable detection for Here is the bug report I just filed: For now I would advise to just include |
Thanks @onqtam , checked on the bug report, interesting chain of events and reasoning. fwiw I tend to agree with Billy O'Neal's assessment of the issue. It looks like this will require a change to doctest as it would be very unfortunate if out of the box experience with vs2019 and onward was unfriendly. Thanks again for the great library. |
It's the right decision for Visual Studio indeed - it's a very niche problem - probably one that only doctest encounters. I'm really reluctant to adding an include just for this though... So I'll have to think about this - don't expect a resolution soon - sorry :| |
No worries at all, I've worked around it for now and have no other issues! |
I had the same problem building on macOS 10.14, note that it works in Debug mode, but fails in Release. A quick look in libc++ files shows that the |
I’m using VS2019. The posted solution (manually including in every test cpp file, tried before and after "doctest.h") fixes some errors, but I still get error lnk2001:
|
@atimholt judging by the linker errors I would say the reason is that you have forgotten to implement the test runner using either DOCTEST_CONFIG_IMPLEMENT or DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN - one of these 2 identifiers must be defined in exactly one .cpp file before including the framework header because doctest.h is actually a header file and a .cpp file bundled together in a single header file, and the .cpp part needs to be compiled somewhere - checkout the relevant docs for supplying your own main. |
Actually, I’m just a moron. Didn’t put |
@theodelrieu are you sure you had the same problem on OSX? Was it a compiler error or was it a linker error like reported here: #126 ...? If your problem is a linker error perhaps you might try the dev branch - I just pushed a fix recently for #126. You mentioned that the failure is only in Release - that could be precisely the same issue which agurtovoy reported here: #126 (comment) |
I just pushed a fix for this in the dev branch - will release in an official version soon: 1fe42c9 |
Looks like the same problem indeed. |
Description
Tests involved a
CHECK
onstd::string
values will not compile in Visual Studio 2019 preview. It appears this is because<string>
in this version does not drag in<ostream>
anymore.Steps to reproduce
Extra information
`/showIncludes' for VS2017 (will compile)
`/showIncludes' for VS2019 Preview (will NOT compile)
The text was updated successfully, but these errors were encountered: