【问题标题】:Keil uVision4 armcc: Using C++ standard includes <cstdint>Keil uVision4 armcc:使用 C++ 标准包括 <cstdint>
【发布时间】:2012-10-19 01:58:09
【问题描述】:

我正在使用 Keil uVision4 在 STM32F2 设备上进行开发。 我正在尝试使用 C++,这应该可以使用 uVision 工具链提供的 armcc(如果我错了,请纠正我)。 但是uVision拒绝接受标准的C++包含方式

    #include <cstdint>

不工作

    #include <stdint.h>

完美运行。 当我在 uVision(右键单击,打开文档)中打开 cstdint 时,它会打开文件,但作为通用文件,例如不是头文件,没有花哨的颜色。

我错过了什么?两个文件都在同一个文件夹中 C:\Keil\ARM\ARMCC\include 并且我是否强制编译器使用c++(通过附加--cpp)没有任何区别。 uVision 只是无法接受没有结尾的文件作为头文件吗?

编辑:响应答案(感谢您的宝贵时间!): 错误消息是:

    #include <cstdint> and
    #include <cstdint.h>
    typedef uint32_t u32;
    error: #20: identifier uint32_t is undefined

同时

    #include <stdint.h> and
    #include <stdint>
    typedef uint32_t u32;
    and 
    #include <cstdint> 
    typedef std::uint32_t u32;
    works perfectly.

这表明了问题所在。感谢您的帮助!

【问题讨论】:

  • 尝试复制cstdint 并将其命名为cstdint.h(不是作为解决方案,而是为了测试您的理论)
  • 你知道&lt;cstdint&gt; 刚刚被添加到 C++11 中,对吧?它不是 C++98 和 C++03 的一部分

标签: c++ include stm32 keil


【解决方案1】:

什么症状你得到它不起作用? IE。错误信息是什么?可能您只需要一个using namespace std,或者在所有类型前面加上std::前缀,因为cstdint标头将其声明放在std命名空间中。

但是请注意,cstdint 是一个非常新的标头,您的编译器可能不支持。所以你可能不得不接受stdint.h,这同样好。

【讨论】:

    猜你喜欢
    • 2021-03-07
    • 2019-02-25
    • 1970-01-01
    • 2016-02-17
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 2019-06-19
    • 2017-11-26
    相关资源
    最近更新 更多