2013-10-29 47 views
1

我想在Windows 7 x64上的AVR UC3C0512C IAR工作台v6.3.3上编译CppUtest库,但是当我编译它时,它说std名称空间是没有定义的。IAR工作台不会找到std :: string

这里是剪断的代码,我得到的第一个错误,该文件是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; 

enter image description here

在库配置我选择普通DLIB,我也试图与全DLIB但IAR无法看到std库

enter image description here

有什么想法吗?

+1

AVR由GCC完全支持ISO C++,而不是EC++支持。 EC++很大程度上已经过时。 – Clifford

+0

我们正在将项目迁移到GCC,但这不是一件容易的事。 –

回答

3

按照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 
+1

@SnakeSanders:在这种情况下,我会建议使用编译器命令行宏定义(我猜测在“预处理器”选项选项卡上),而不是'#define'来维护代码的可移植性,而无需删除定义或添加有条件编译 - 它也是将定义全局添加到所有现有和第三方代码的最简单方法。 – Clifford