2013-10-29 73 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