找不到#define 的函数定义

Function definition not found for #define

我的一个宏出现奇怪的错误。名称已更改,但除此之外,代码与我的项目中的代码完全相同。它的目的是自动完成我在代码中多次编写的过程。

#ifdef add
#undef add
#endif
#define add(name, temp)             \
struct name<temp>                   \
{                                   \
    static constexpr r = true;      \
}

错误如下:

Function definition for 'add' not found.

explicit type is missing ('int' assumed)

它正确地扩展了代码并向我展示了这一点,但它似乎对正在发生的事情非常困惑,或者我不明白错误。

我正在使用 Visual Studio 2019,所以 VC++19 编译器。

我认为您忘记了编译器消息建议的 bool 关键字,但 int

#ifdef add
#undef add
#endif
#define add(name, temp)             \
struct name<temp>                   \
{                                   \
    static constexpr bool r = true;      \
}