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

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?
Did you try
"#include <mutex>"

Tim S.
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
<thread> includes <mutex>.
But this is not the problem...
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?
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!
The C++0x thread library should be the same as the boost one.
The only difference is the namespace
@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.