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

[bug] Can't compile the tests because of mutex, that is declared in the doctest #242

Closed
BrunaoW opened this issue Jun 6, 2019 · 8 comments

Comments

@BrunaoW
Copy link

BrunaoW commented Jun 6, 2019

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.

  • doctest version: latest
  • Operating System: Windows 10
  • Compiler+version: MinGW GCC Compiler, version 6,3,0
@onqtam
Copy link
Member

onqtam commented Jun 10, 2019

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.

@BrunaoW
Copy link
Author

BrunaoW commented Jun 10, 2019

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!

@onqtam
Copy link
Member

onqtam commented Jun 11, 2019

I'm closing this since it is not a problem that the framework is using a standard C++11 header :)

@onqtam onqtam closed this as completed Jun 11, 2019
@KratochvilDavid
Copy link

KratochvilDavid commented Jan 14, 2022

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:
DIR/doctest/doctest/doctest.h: In constructor 'doctest::{anonymous}::FatalConditionHandler::FatalConditionHandler()':
DIR/doctest/doctest/doctest.h:4499:48: error: no matching function for call to 'sigaltstack::sigaltstack(stack_t*, stack_t*)'
4499 | sigaltstack(&sigStack, &oldSigStack);
| ^
In file included from /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/signal.h:6,
from DIR/doctest/doctest/doctest.h:385,
from DIR/unittests/unit_test_main.cpp:8:
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'sigaltstack::sigaltstack()'
153 | typedef struct sigaltstack {
| ^~~~~~~~~~~
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 0 arguments, 2 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'constexpr sigaltstack::sigaltstack(const sigaltstack&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 1 argument, 2 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'constexpr sigaltstack::sigaltstack(sigaltstack&&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 1 argument, 2 provided
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h:4502:35: error: 'SA_ONSTACK' was not declared in this scope
4502 | sa.sa_flags = SA_ONSTACK;
| ^~~~~~~~~~
DIR/doctest/doctest/doctest.h:4504:67: error: no matching function for call to 'sigaction::sigaction(int&, sigaction*, sigaction*)'
4504 | sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
| ^
In file included from /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/signal.h:6,
from DIR/doctest/doctest/doctest.h:385,
from DIR/unittests/unit_test_main.cpp:8:
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'sigaction::sigaction()'
121 | struct sigaction
| ^~~~~~~~~
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 0 arguments, 3 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'constexpr sigaction::sigaction(const sigaction&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 1 argument, 3 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'constexpr sigaction::sigaction(sigaction&&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 1 argument, 3 provided
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h: In static member function 'static void doctest::{anonymous}::FatalConditionHandler::reset()':
DIR/doctest/doctest/doctest.h:4513:75: error: no matching function for call to 'sigaction::sigaction(int&, sigaction*, std::nullptr_t)'
4513 | sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
| ^
In file included from /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/signal.h:6,
from DIR/doctest/doctest/doctest.h:385,
from DIR/unittests/unit_test_main.cpp:8:
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'sigaction::sigaction()'
121 | struct sigaction
| ^~~~~~~~~
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 0 arguments, 3 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'constexpr sigaction::sigaction(const sigaction&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 1 argument, 3 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate: 'constexpr sigaction::sigaction(sigaction&&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:121:8: note: candidate expects 1 argument, 3 provided
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h:4516:50: error: no matching function for call to 'sigaltstack::sigaltstack(stack_t*, std::nullptr_t)'
4516 | sigaltstack(&oldSigStack, nullptr);
| ^
In file included from /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/signal.h:6,
from DIR/doctest/doctest/doctest.h:385,
from DIR/unittests/unit_test_main.cpp:8:
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'sigaltstack::sigaltstack()'
153 | typedef struct sigaltstack {
| ^~~~~~~~~~~
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 0 arguments, 2 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'constexpr sigaltstack::sigaltstack(const sigaltstack&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 1 argument, 2 provided
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate: 'constexpr sigaltstack::sigaltstack(sigaltstack&&)'
/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/signal.h:153:16: note: candidate expects 1 argument, 2 provided
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h: At global scope:
DIR/doctest/doctest/doctest.h:4525:64: error: 'SIGSTKSZ' was not declared in this scope; did you mean 'SIGSYS'?
4525 | size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ;
| ^~~~~~~~
| SIGSYS
DIR/doctest/doctest/doctest.h:5095:14: error: 'mutex' in namespace 'std' does not name a type
5095 | std::mutex mutex;
| ^~~~~
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h:2965:1: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
2964 | #include <unistd.h>
+++ |+#include
2965 |
In file included from DIR/unittests/unit_test_main.cpp:8:
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::test_case_exception(const doctest::TestCaseException&)':
DIR/doctest/doctest/doctest.h:5255:34: error: 'mutex' is not a member of 'std'
5255 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5255:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5255:39: error: template argument 1 is invalid
5255 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5255:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5255 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:5255:41: error: unused variable 'lock' [-Werror=unused-variable]
5255 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::log_assert(const doctest::AssertData&)':
DIR/doctest/doctest/doctest.h:5276:34: error: 'mutex' is not a member of 'std'
5276 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5276:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5276:39: error: template argument 1 is invalid
5276 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5276:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5276 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
"make" -C /home/user/projects/riot/sys/luid
DIR/doctest/doctest/doctest.h:5276:41: error: unused variable 'lock' [-Werror=unused-variable]
5276 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::XmlReporter::log_message(const doctest::MessageData&)':
DIR/doctest/doctest/doctest.h:5302:34: error: 'mutex' is not a member of 'std'
5302 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5302:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5302:39: error: template argument 1 is invalid
5302 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5302:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5302 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:5302:41: error: unused variable 'lock' [-Werror=unused-variable]
5302 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: At global scope:
DIR/doctest/doctest/doctest.h:5385:14: error: 'mutex' in namespace 'std' does not name a type
5385 | std::mutex mutex;
| ^~~~~
DIR/doctest/doctest/doctest.h:5385:9: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
5385 | std::mutex mutex;
| ^~~
"make" -C /home/user/projects/riot/sys/malloc_thread_safe
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::JUnitReporter::test_case_exception(const doctest::TestCaseException&)':
DIR/doctest/doctest/doctest.h:5553:34: error: 'mutex' is not a member of 'std'
5553 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5553:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5553:39: error: template argument 1 is invalid
5553 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5553:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5553 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:5553:41: error: unused variable 'lock' [-Werror=unused-variable]
5553 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::JUnitReporter::log_assert(const doctest::AssertData&)':
DIR/doctest/doctest/doctest.h:5567:34: error: 'mutex' is not a member of 'std'
5567 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5567:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5567:39: error: template argument 1 is invalid
5567 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5567:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5567 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:5567:41: error: unused variable 'lock' [-Werror=unused-variable]
5567 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: At global scope:
DIR/doctest/doctest/doctest.h:5618:14: error: 'mutex' in namespace 'std' does not name a type
5618 | std::mutex mutex;
| ^~~~~
DIR/doctest/doctest/doctest.h:5618:9: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
5618 | std::mutex mutex;
| ^~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::test_case_exception(const doctest::TestCaseException&)':
DIR/doctest/doctest/doctest.h:5995:34: error: 'mutex' is not a member of 'std'
5995 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:5995:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:5995:39: error: template argument 1 is invalid
5995 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:5995:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
5995 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:5995:41: error: unused variable 'lock' [-Werror=unused-variable]
5995 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::log_assert(const doctest::AssertData&)':
DIR/doctest/doctest/doctest.h:6034:34: error: 'mutex' is not a member of 'std'
6034 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:6034:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:6034:39: error: template argument 1 is invalid
6034 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:6034:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
6034 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:6034:41: error: unused variable 'lock' [-Werror=unused-variable]
6034 | std::lock_guardstd::mutex lock(mutex);
| ^~~~
DIR/doctest/doctest/doctest.h: In member function 'virtual void doctest::{anonymous}::ConsoleReporter::log_message(const doctest::MessageData&)':
DIR/doctest/doctest/doctest.h:6050:34: error: 'mutex' is not a member of 'std'
6050 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
DIR/doctest/doctest/doctest.h:6050:34: note: 'std::mutex' is defined in header ''; did you forget to '#include '?
DIR/doctest/doctest/doctest.h:6050:39: error: template argument 1 is invalid
6050 | std::lock_guardstd::mutex lock(mutex);
| ^
DIR/doctest/doctest/doctest.h:6050:46: error: 'mutex' was not declared in this scope; did you mean 'mutex_t'?
6050 | std::lock_guardstd::mutex lock(mutex);
| ^~~~~
| mutex_t
DIR/doctest/doctest/doctest.h:6050:41: error: unused variable 'lock' [-Werror=unused-variable]
6050 | std::lock_guardstd::mutex lock(mutex);

@Saalvage Saalvage reopened this Jan 14, 2022
@Saalvage
Copy link
Member

@dakrt What compiler are you using? It's likely not fully C++11 compliant.
Maybe try the DOCTEST_CONFIG_NO_POSIX_SIGNALS flag, it should at least get rid of the errors related to sigaltstack.

@KratochvilDavid
Copy link

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
g++: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
g++: error: unrecognized command line option ‘-mno-thumb-interwork’
g++: error: unrecognized command line option ‘-mlittle-endian’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mfloat-abi=hard’
g++: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
g++: error: unrecognized command line option ‘-mfpu=fpv4-sp-d16’
make[2]: *** [riot/Makefile.base:162: unittests/bin/test.o] Error 1
make[1]: *** [riot/Makefile.base:31: ALL--] Error 2
make[1]: *** Waiting for unfinished jobs....
g++: error: unrecognized command line option ‘-mno-thumb-interwork’
g++: error: unrecognized command line option ‘-mno-thumb-interwork’
g++: error: unrecognized command line option ‘-mlittle-endian’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mlittle-endian’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mfloat-abi=hard’
g++: error: unrecognized command line option ‘-mfloat-abi=hard’
g++: error: unrecognized command line option ‘-mfpu=fpv4-sp-d16’
make[2]: *** [riot/Makefile.base:162: unittests/bin/tcp_server/tcp_server.o] Error 1
make[1]: *** [riot/Makefile.base:31: ALL--modules/tcp_server] Error 2
g++: error: unrecognized command line option ‘-mfpu=fpv4-sp-d16’
make[2]: *** [riot/Makefile.base:162: unittests/bin/SvDecoder.o] Error 1
make[1]: *** [riot/Makefile.base:31: ALL--modules] Error 2
g++: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
g++: error: unrecognized command line option ‘-mno-thumb-interwork’
g++: error: unrecognized command line option ‘-mlittle-endian’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mfloat-abi=hard’
g++: error: unrecognized command line option ‘-mfpu=fpv4-sp-d16’

@Saalvage
Copy link
Member

  1. If your makefile system is similar to cmake then you'd have to use something akin to -D DOCTEST_CONFIG_NO_POSIX_SIGNALS, since it is just a macro flag that is relevant to the code itself.
  2. So stackoverflow gives the following answer: "arm-none-eabi means a system with no OS, just bare metal, so you don't have most of the standard library, so no pthreads (which GCC's std::mutex is built on top of)." Meaning that mutices are indeed not available to you.

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.

@Saalvage
Copy link
Member

The new DOCTEST_CONFIG_NO_MULTITHREADING option should definitely fix this. If it doesn't, please reopen!

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

4 participants