3

我在 clang 上有一个编译错误,并在 gcc 中使用以下代码发出警告:

static alignas(16) int one_s = 1;                      // clang: error: an attribute list cannot appear here; gcc: warning: attribute ignored;
static __attribute__((aligned(16))) int zero_s = 0;    // on the other hand this works well on both compilers...
alignas(16) int one = 1;                               // this also works on both compilers
__attribute__((aligned(16))) int zero = 0;             // as well as this

有谁知道为什么在包含 static 关键字的声明中不接受 alignas ?我将 --std=c++11 编译器选项与 gcc 和 clang 一起使用。(编辑:我使用了 clang 3.4 及更高版本和 gcc 4.8 及更高版本)

请注意,在使用 Visual Studio (CL 19 RC) 进行编译时,在这样的静态声明中使用 alignas 时不会出现错误。

4

0 回答 0