我正在使用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.这就说明了问题所在。谢谢你的帮助!
发布于 2012-10-30 02:03:35
你有什么症状到它不工作了?也就是说,错误消息是什么?您可能只需要一个using namespace std,或者在所有类型前面加上std::前缀,因为cstdint标头将其声明放在std名称空间中。
但是请注意,cstdint是一个非常新的头文件,您的编译器可能不支持它。因此,您可能不得不接受stdint.h,它也一样好。
https://stackoverflow.com/questions/13126957
复制相似问题