std::mutex
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: std::mutex

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    726

    std::mutex

    I was looking at some open source project that I thought was interesting and wanted to compile the code for myself. Unfortunately my visual studio 2010 isn't c++11 compliant enough so I installed gcc/g++ 4.7.2 and that doesn't work either

    Here is a snippet that shows my problem.
    Code:
    > g++ --version
    
    g++ (GCC) 4.7.2
    Copyright (C) 2012 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Code:
    #include <mutex>
    
    int main()
    {
      std::mutex mutex_;
    
      return 0;
    }
    Code:
    >g++ -std=c++11 main.cpp
    
    main.cpp: In function 'int main()':
    main.cpp:5:2: error: 'mutex' is not a member of 'std'
    main.cpp:5:13: error: expected ';' before 'mutex_'
    Any help welcomed.

  2. #2
    Join Date
    Oct 2012
    Posts
    9

    Re: std::mutex

    Hmm..Are you using on Linux?

  3. #3
    Join Date
    Apr 2008
    Posts
    726

    Re: std::mutex

    no... visual studio doesn't work too well on linux.

  4. #4
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,109

    Re: std::mutex

    I only have g++ 4.6.1, but looking at /usr/local/include/c++/4.6.1/mutex it seems that the mutex class is protected by some #defines.
    I found a (german) article on the web which mentions that you must have installed the pthread library.

    HTH,
    Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center