1

I have some code that I am compiling for an embedded platform. When I attempt to run a Clang-based tool against the code I get some errors.

I have narrowed down the code that generates the errors to the following:

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;

The output from running clang 3.8.0 against the code is:

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.

Why does it have the issue only on the _int8 typedef and not the other typedefs? Also, what does the error mean?

Graznarak
  • 3,626
  • 4
  • 28
  • 47
  • 2
    `_int8` is probably defined to be some type somewhere already. I can't reproduce this on wandbox. – T.C. May 18 '16 at 23:34
  • I built Clang 3.8.0 on Windows 10 using Visual Studio 2015. I compiled it using `clang.exe x.cpp`. – Graznarak May 18 '16 at 23:43
  • 1
    As a side note identifiers starting with an underscore followed by a capital letter are reserved by the implementation. Unless the code in question is provided by the compiler/vendor it's incorrect. See http://stackoverflow.com/a/228797/845568 for more information. – Captain Obvlious May 18 '16 at 23:45
  • 1
    Ah, OK, reproduced with `-fms-extensions`; in that mode it treats `_int8` as a keyword, equivalent to `char`. – T.C. May 18 '16 at 23:46
  • That makes sense. I added `-fno-ms-extensions` and it fixed it. Thanks. – Graznarak May 18 '16 at 23:50

1 Answers1

5

Clang on Windows has -fms-extensions on by default, and in that mode _int8 is a keyword equivalent to char, because that's apparently what MSVC does.

Disable it with -fno-ms-extensions.

T.C.
  • 133,968
  • 17
  • 288
  • 421