samedi 29 juillet 2023

namespace "std" has no member "mutex"

I'm using mingw64 and even a simple program like this failed to compile. Moreover g++ is suggesting a revolutionary solution.

The code-

#include <mutex>

int main()
{
  std::mutex m;
}

The error-

test.cpp: In function 'int main()':
test.cpp:5:8: error: 'mutex' is not a member of 'std'
   std::mutex m;
    ^~~~~

The solution-

test.cpp:5:8: note: 'std::mutex' is defined in header '<mutex>'; did you forget to'#include <mutex>'?
test.cpp:2:1:
+#include <mutex>
 
test.cpp:5:8:
   std::mutex m;
        ^~~~~

How do I compile this?

Aucun commentaire:

Enregistrer un commentaire