错误:“互斥体"未命名类型 [英] error: 'mutex' does not name a type

查看:56
本文介绍了错误:“互斥体"未命名类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用arm-none-eabi-g ++工具链在ubuntu中尝试以下代码时,出现编译错误:

When I am try the following code in ubuntu with arm-none-eabi-g++ tool chain i was getting compilation errors:

#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:错误:互斥体"未命名互斥体mtx类型;//关键部分的互斥体

mt.cc:5:1: error: 'mutex' does not name a type mutex mtx; // mutex for critical section

^

gcc版本:

gcc版本4.8.4 20140725(发行版)[ARM/embedded-4_8-branch修订版213147](用于ARM嵌入式处理器的GNU工具)

gcc version 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147] (GNU Tools for ARM Embedded Processors)

推荐答案

您的评论正确:

#include  <mutex>    // std::mutex    

但是随后您没有得到正确的代码:

But then you didn't get the code right:

mutex mtx;           // mutex for critical section

应为 std :: mutex

这篇关于错误:“互斥体"未命名类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆