表达式不能用作宏扩展中的函数

Expression cannot be used as a function in expansion of macro

我正在尝试编译一些代码(使用 GCC 4.8.2)并得到一个 error: expression cannot be used as a function

这是相关代码。

debug.h

// A macro for code which is not expected to be reached under valid assumptions
#if !defined(NDEBUG)
#define UNREACHABLE() do { \
    ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
    assert(false); \
    } while(0)
#else 
    #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
#endif

someFile.cpp(只有默认行才是真正相关的)

HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor(ShShaderOutput outputType)
{
    switch (outputType)
    {
      case SH_HLSL9_OUTPUT: return ENCODE_LOOSE;
      case SH_HLSL11_OUTPUT: return ENCODE_PACKED;
      default: UNREACHABLE(); return ENCODE_PACKED;
    }
}

错误:

/.../debug.h:123:90: error: expression cannot be used as a function
     #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
                                                                                          ^
/.../someFile.cpp:217:16: note: in expansion of macro 'UNREACHABLE'
       default: UNREACHABLE(); return ENCODE_PACKED;
                ^

我正在尝试了解为什么会发生错误。查看 this question I thought maybe the issue was that the function (HLSL...) was being used as a variable due to __FUNCTION__ in the macro. But according to the GCC documentation: "GCC provides three magic variables which hold the name of the current function, as a string",所以我认为这不是问题所在。还有其他想法吗?

用我找到的解决方案更新这个。

感谢上面那些告诉我要进一步调查 ERR 的人。事实证明,另一个头文件中有一个 ERR 的重复定义,这似乎导致了我的错误。更改 debug.h 中 ERR 的定义以避免此冲突解决了我的问题。 :)