【发布时间】: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(不是作为解决方案,而是为了测试您的理论) -
你知道
<cstdint>刚刚被添加到 C++11 中,对吧?它不是 C++98 和 C++03 的一部分