This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC rejecting (I think) valid code



On Jan 23, 2005, at 6:05 AM, Andreas Schwab wrote:


"Sam Lauber" <sam124@operamail.com> writes:

I compile this pair of declarations with GCC (which would
probably be found in a stdint.h):

typedef short int16_t;
typedef unsigned int16_t uint16_t;

The first declaration is OK, but GCC gives me an error on
the second one. That dosen't make sense, because part of
the C89 grammar is

type-name:
(some types) typedef-name

typedef-declaration: something like
`typedef' type-name typedef-name

There is more to C than the syntax. The standard also contains semantic
constraints that are to be applied on top of the syntax. I can't check
C89, but in C99 section 6.7.2 contains an exhaustive list of allowed
type-specifier sets in a type-name, and this list only allows a single
typedef-name not mixed with other type-specifiers for each type-name.

C90 has the same list in 3.5.2. An example in 3.5.6 sheds some light on why:
consider


struct {
   unsigned int16_t:4;
};


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]