new*_*mer 16 gcc mingw g++ c++11
我从官方网站下载了MinGW版本:http://sourceforge.net/projects/mingw/files/并将其安装在我的Windows 7机器上.
运行g++ --version给了我g++.exe (GCC) 4.8.1,我相信GCC 4.8.1支持C++ 11功能,包括线程.
运行g++ -std=c++11 main.cpp成功编译以下程序.
//main.cpp
#include <memory>
int main() {
std::unique_ptr<int> a(new int);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但运行g++ -std=c++11 main.cpp以下程序:
//main.cpp
#include <mutex>
int main() {
std::mutex myMutex;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
给出错误:
main.cpp: In function `int main()`:
main.cpp:5:5: error: 'mutex' is not a member of 'std'
std::mutex myMutex;
^
main.cpp:5:16: error: expected ';' before 'myMutex'
std::mutex myMutex;
^
Run Code Online (Sandbox Code Playgroud)
好像<mutex>不受支持.编译器没有抱怨#include <mutex>所以我不知道为什么我会收到这个错误.
已经存在std :: thread和sync原语的本机win32实现:https: //github.com/meganz/mingw-std-threads 它是一个仅限头的库,应该适用于任何符合C++ 11的版本MinGW的.
| 归档时间: |
|
| 查看次数: |
14505 次 |
| 最近记录: |