为什么它不能与之前的声明说明符结合使用"

时间:2016-05-18 23:31:50

标签: c++ c++11

我有一些代码,我正在编译嵌入式平台。当我尝试针对代码运行基于Clang的工具时,我遇到了一些错误。

我已将生成错误的代码缩小到以下内容:

typedef int _GCC_ATTR_ALIGN_8t __attribute__((__mode__(__QI__)));
typedef _GCC_ATTR_ALIGN_8t _Int8t __attribute__((__aligned__(1)));
typedef _Int8t _Intleast8t;
typedef _Int8t _Intfast8t;
typedef _Int8t _int8;
typedef _Int8t int8_t;

运行clang 3.8.0对代码的输出是:

x.cpp:5:16: error: cannot combine with previous 'type-name' declaration
      specifier
typedef _Int8t _int8;
               ^
x.cpp:5:1: warning: typedef requires a name [-Wmissing-declarations]
typedef _Int8t _int8;
^~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.

为什么它只在_int8 typedef而不是其他typedef上有问题?此外,错误意味着什么?

1 个答案:

答案 0 :(得分:5)

Windows上的Clang默认情况下启用-fms-extensions,并且在该模式下_int8 is a keyword equivalent to char,因为这显然是MSVC所做的。

使用-fno-ms-extensions禁用它。

相关问题