C++0x mutex don't compile on minGW

Feb 14, 2011 at 4:14pm
Hi,
I have this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <thread>

using namespace std;

class TryMutex
{
    public:
        TryMutex();
        virtual ~TryMutex();
    protected:
    private:
    mutex myMutex;
};


myMutex is an instance of std::mutex, a new C++0x class for multithreading.

This code compiles fine on Linux with GCC/G++ 4.5.1, but under Window with minGW (GCC/G++) 4.5.2 I have this error on compiling:

error: 'mutex' does not name a type

Why?
Feb 14, 2011 at 6:18pm
Did you try
"#include <mutex>"

Tim S.
Feb 14, 2011 at 7:08pm
I wonder how many (tens of) years have to pass until they finally fix that header hell and provide true, first-class modularity. Even something like Pascal had 10 years ago would be a big step forward (but being able to selectively import things into the namespace would be better).
Last edited on Feb 14, 2011 at 7:11pm
Feb 14, 2011 at 11:29pm
<thread> includes <mutex>.
But this is not the problem...
Feb 15, 2011 at 3:44am
Is it possible that std::mutex support is completely missing from minGW? Have you tried the Boost Thread library to see if that works with minGW?
Feb 15, 2011 at 12:03pm
Yes, it is possible but it's strange, the compiler version is the same as Linux.

I would not use boost.thread because I would not change anything in my code!
Feb 15, 2011 at 12:47pm
The C++0x thread library should be the same as the boost one.
The only difference is the namespace
Feb 15, 2011 at 2:49pm
@Bazzy: I'm not so sure. I seem to recall a post on the Boost mailing list about getting GSoC help to update the thread library to better match the C++0x draft standard.
Topic archived. No new replies allowed.