2014-06-28 68 views
0

我試圖編譯我的項目與英特爾C++編譯器,但我發現許多錯誤,像這樣的:錯誤:標識符「__func__」未定義與ICC

1>..\src\luascript.cpp(5889): error : identifier "__func__" is undefined 
1>   reportErrorFunc(getErrorDesc(LUA_ERROR_ITEM_NOT_FOUND)); 
1>  ^

我編譯這個項目與MS Visual Studio之前並沒有警告或錯誤,但與ICC我得到這個。下面是代碼產生錯誤

int32_t LuaScriptInterface::luaNetworkMessageAddItem(lua_State* L) 
{ 
    // networkMessage:addItem(item) 
    Item* item = getUserdata<Item>(L, 2); 
    if (!item) { 
     reportErrorFunc(getErrorDesc(LUA_ERROR_ITEM_NOT_FOUND)); //This is the line that the error points to 
     lua_pushnil(L); 
     return 1; 
    } 

    //... 
} 

定義的部分reportErrorFunc是:

#define reportErrorFunc(a) reportError(__FUNCTION__, a, true) 

還有:

#ifndef __FUNCTION__ 
#define __FUNCTION__ __func__ 
#endif 

請讓我知道如果你需要我發佈代碼

我在Windows 7 SP1 x64上使用MSVC 2013 Ultimate和Intel C++ Studio XE 2013 SP1 U2

+0

的問題大概是在'reportErrorFunc'宏的定義。 – Barmar

+0

@Barmar其定義如下:'''#define reportErrorFunc(a)reportError(__ FUNCTION__,a,true)''' – user3084450

+0

繼續擴展宏 - 其中必須包含'__func__'。 – Barmar

回答

1

根據Intel XE的版本,__func__預先聲明的標識符可能可用,也可能不可用。確保您使用/Qstd=c++11來啓用其可用性。

更多信息availble的爲:

https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler

+1

沒有'func'關鍵字。 '__func__'就像一個特殊的變量。 – chris

+1

@chris呃,我忘了引用它,修復。降級將'_'__strong __ \''作爲'__strong__'中的一個強壯變成__strong__,而沒有'\''' –

+0

我甚至沒有考慮過這個問題。 – chris

相關問題