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
[bug] Can't compile the tests because of mutex, that is declared in the doctest #242
Comments
I guess your version of MinGW doesn't fully support everything from C++11 - mainly threading. I'd suggest that you use MinGW-w64 - just extract it somewhere and add the bin folder to the PATH env var (the link is for GCC 8.1). They also have an official website with installers: https://mingw-w64.org/ In my opinion the original MinGW is lagging behind in support for C++ features and MinGW-w64 is the proper version to use for a few years now. If you try with VS 2017 or 2019 on windows doctest will work as well. |
Both of the solutions worked! Thanks! |
I'm closing this since it is not a problem that the framework is using a standard C++11 header :) |
I have the same problem on my Ubuntu machine when trying to use doctest with a RIOT-OS project. Am I missing some packages? In file included from DIR/unittests/unit_test_main.cpp:8: |
@dakrt What compiler are you using? It's likely not fully C++11 compliant. |
Sorry for not including that information. I am using the RIOT makefile system. This is sometimes quite overwelming and it took me some time to find the answer. When printing out the CXX variable of the makefile it shows that arm-none-eabi-g++ is used in verison (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release). Also I am using the Flag -std=c++1z. Furthermore Flag -DOCTEST_CONFIG_NO_POSIX_SIGNALS does not solve the problem. When I try to utilize g++ by setting the CXX variable RIOT does not compile properly g++: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead |
I feel like this isn't really doctest's fault. Although if you manage to get it working with only the mutices missing then we could look into allowing a flag to disable them. |
The new |
Description
So, I'm trying to learn doctest, but I can't even compile a cpp file just by including doctest.h. When I compile the tutorial example, the following log are showed:
g++ -std=c++11 main.cpp
In file included from main.cpp:2:0:
doctest.h:4750:14: error: 'mutex' in namespace 'std' does not name a type
std::mutex mutex;
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::test_case_exception(const doctest::TestCaseException&)':
doctest.h:4898:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:4898:29: error: 'mutex' is not a member of 'std'
doctest.h:4898:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:4898:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::subcase_start(const doctest::SubcaseSignature&)':
doctest.h:4906:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:4906:29: error: 'mutex' is not a member of 'std'
doctest.h:4906:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:4906:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::log_assert(const doctest::AssertData&)':
doctest.h:4921:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:4921:29: error: 'mutex' is not a member of 'std'
doctest.h:4921:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:4921:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::log_message(const doctest::MessageData&)':
doctest.h:4946:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:4946:29: error: 'mutex' is not a member of 'std'
doctest.h:4946:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:4946:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: At global scope:
doctest.h:4989:14: error: 'mutex' in namespace 'std' does not name a type
std::mutex mutex;
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::subcase_start(const doctest::SubcaseSignature&)':
doctest.h:5353:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:5353:29: error: 'mutex' is not a member of 'std'
doctest.h:5353:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:5353:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::subcase_end()':
doctest.h:5359:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:5359:29: error: 'mutex' is not a member of 'std'
doctest.h:5359:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:5359:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::log_assert(const doctest::AssertData&)':
doctest.h:5368:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:5368:29: error: 'mutex' is not a member of 'std'
doctest.h:5368:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:5368:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::log_message(const doctest::MessageData&)':
doctest.h:5413:29: error: 'mutex' is not a member of 'std'
std::lock_guardstd::mutex lock(mutex);
^~~
doctest.h:5413:29: error: 'mutex' is not a member of 'std'
doctest.h:5413:39: error: template argument 1 is invalid
std::lock_guardstd::mutex lock(mutex);
^
doctest.h:5413:46: error: 'mutex' was not declared in this scope
std::lock_guardstd::mutex lock(mutex);
^~~~~
So, as you can see all the messages are related to the mutex declaration, and std namespace.
Steps to reproduce
Just added the lib in the same folder as the main.cpp file, ctrl+c ctrl+v the tutorial example in it, and ran it, lol.
Extra information
I was looking for some answers about the first line of error:
'mutex' in namespace 'std' does not name a type
, and basically everyone said that the mingw default installation of the cpp compiler does not support mutex library, or something like that. However, everyone had this problem using the mutex for threading in their program.The text was updated successfully, but these errors were encountered: