【问题标题】:IAR Workbench can't find std::stringIAR Workbench 找不到 std::string
【发布时间】:2013-11-08 06:17:54
【问题描述】:

我正在尝试在 IAR 工作台 v6.3.3 上为 Windows 7 x64 上的 AVR UC3C0512C 编译 CppUtest 作为库,但是当我编译它时,它说 std 命名空间未定义。

这是我得到第一个错误的代码片段,文件是 SimpleString.h:

#if CPPUTEST_USE_STD_CPP_LIB
  #include <string>
  #include <stdint.h>

  SimpleString StringFrom(const std::string& other);

最后一行包含 std::string,这给我带来了 190 个与此相关的错误。消息是:

Error[Pe276]: name followed by "::" must be a class or namespace name
C:\COM\SRC\cpputest35\include\CppUTest\SimpleString.h 143 

我尝试使用下面的行,但没有帮助:

using namespace std;

在库配置下,我选择普通 DLIB,我也尝试使用完整 DLIB,但 IAR 看不到 std 库

有什么想法吗?

【问题讨论】:

  • AVR 由完全支持 ISO C++ 而不是 EC++ 的 GCC 支持。 EC++ 在很大程度上已经过时了。
  • 我们正在将项目迁移到 GCC,但这不是一件容易的事。

标签: c++ embedded shared-libraries iar


【解决方案1】:

根据 IAR 手册

The std namespace is not used in either standard EC++ or in Extended EC++. If you 
have code that refers to symbols in the std namespace, simply define std as nothing; 
for example:
#define std // Nothing here

【讨论】:

  • @SnakeSanders:在这种情况下,我建议使用编译器命令行宏定义(我猜是在“预处理器”选项选项卡上),而不是 #define 来维护代码的可移植性而不需要删除定义或在其周围添加条件编译 - 这也是将定义全局添加到所有现有和第三方代码的最简单方法。
猜你喜欢
  • 2013-06-21
  • 2015-10-18
  • 2013-10-20
  • 1970-01-01
  • 2021-01-10
  • 1970-01-01
  • 2021-01-08
  • 1970-01-01
  • 2018-03-08
相关资源
最近更新 更多