Search code examples
c++visual-c++icc

error : identifier "__func__" is undefined with ICC


I'm trying to compile my project with Intel's C++ Compiler but I'm getting many errors like these:

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

I've compiled this project with MS Visual Studio before and got no warnings or errors but with ICC I get this. Here is the section of code that produces that error

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;
    }

    //...
}

The definition reportErrorFunc is:

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

There is also:

#ifndef __FUNCTION__
#define __FUNCTION__ __func__
#endif

Please let me know if you need me to post anymore code

I'm on Windows 7 SP1 x64 with MSVC 2013 Ultimate and Intel C++ Studio XE 2013 SP1 U2


Solution

  • Depending on the version of Intel XE the __func__ predeclared identifier may or may not be available. Make sure you use /Qstd=c++11 to enable its availability.

    More information is availble at:

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