【发布时间】:2016-07-05 03:02:03
【问题描述】:
当我在 ubuntu 中使用 arm-none-eabi-g++ 工具链尝试以下代码时,我遇到了编译错误:
#include <iostream>
#include <thread> // std::thread
#include <mutex> // std::mutex
mutex mtx; // mutex for critical section
int main ()
{
return 0;
}
编译命令:
arm-none-eabi-g++ -Os -Wall -std=c++11 -fno-rtti -fno-exceptions -c mt.cc
编译错误:
mt.cc:5:1: 错误:'mutex' 没有命名类型 mutex mtx; // 关键部分的互斥锁
^
gcc 版本:
gcc 版本 4.8.4 20140725(发布)[ARM/embedded-4_8-branch 修订版 213147](用于 ARM 嵌入式处理器的 GNU 工具)
【问题讨论】:
-
@venkat 你忘了
std::。 -
@Idos,不,不是同一个问题。
-
我确实尝试过 std:: 起初这是我得到的错误“mt.cc:5:1: error: 'mutex' in namespace 'std' does not name a type std: :mutex mtx; // 临界区互斥"