我試圖編譯我的項目與英特爾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
的問題大概是在'reportErrorFunc'宏的定義。 – Barmar
@Barmar其定義如下:'''#define reportErrorFunc(a)reportError(__ FUNCTION__,a,true)''' – user3084450
繼續擴展宏 - 其中必須包含'__func__'。 – Barmar