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

Link problem w/ BUILD=Release if MESSAGE() with std::string/ostream-operator is used #316

Closed
jenisys opened this issue Dec 8, 2019 · 2 comments

Comments

@jenisys
Copy link

jenisys commented Dec 8, 2019

Description

A linker occurs in BUILD=Release if a test case uses the MESSAGE() macro together with a std::string parameter and the stream-operator. The same test program compiles without problems with BUILD=Debug.

HINT: A #include <iostream> fixes the problem in BUILD=Release.

Steps to reproduce

// -- FILES: test_syndrome.cpp
// #define FIX_RELEASE_SYNDROME_LINKER_PROBLEM  0
// #define FIX_RELEASE_SYNDROME_LINKER_PROBLEM  1  // FIXES LINKER-PROBLEM
#include "doctest/doctest.h"
#  include <string>
#if FIX_RELEASE_SYNDROME_LINKER_PROBLEM
#  include <iostream>
#endif

namespace {

// -- SYNDROME in BUILD=Release:
// MESSAGE w/ stream-operator causes link-problem if #include <iostream> is missing
TEST_CASE("Use MESSAGE w/ ostream-operator (std::string, RELEASE-SYNDROME)")
{
    const std::string name{"Alice"};
    MESSAGE("Hello "<< name);
}

} //< NAMESPACE-END

Extra information

  • doctest version: v2.3.5 (and current HEAD of master and before ...)
  • Operating System: macOS 10.14
  • Compiler+version: Apple Clang v10.0.1
@onqtam
Copy link
Member

onqtam commented Dec 9, 2019

Thanks for the report! This is actually a duplicate: #126
I tried solving it a few times before... I suggest you use the workaround of including <iostream> for now - I hope I get back to trying to fix this in a month or two...

There is an open PR for this: #314 - the idea behind the PR is to include <ostream> when DOCTEST_CONFIG_USE_STD_HEADERS is defined... I'm still not sure how to continue forward with this.

@jenisys
Copy link
Author

jenisys commented Dec 11, 2019

Ok, thanks for the info.

@jenisys jenisys closed this as completed Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants