#define __attribute__((always_inline)) c/c++ 中的评估

#define __attribute__((always_inline)) evaluation in c/c++

我有这个宏:

#define INLINE __attribute((always_inline)) inline

我想让它变成这样:

INLINE void DoStuff() {

}

进入这个:

__attribute__((always_inline)) inline void DoStuff() {

}

但我在编译时收到此错误:"declaration does not declare anything" 在宏的扩展中。我做错了什么?

这是 gcc 系列编译器的正确方法

#define INLINE inline __attribute__((always_inline))

int INLINE add(int x, int y)
{
    return x + y;
}


int main()
{
    printf("%d", add(rand(), rand()));
}

https://godbolt.org/z/BM6Wjw