On 31 January 2011 08:59, Ralf Corsepius <ralf.corsep...@rtems.org> wrote: > Hi, > > gcc emits an error, when compiling this code-snippet: > > --- snip --- > extern int x; > > void > foo (void) > { > x = sizeof ((long)); > } > --- snip --- > > # gcc -Wall -o tmp.o -c tmp.c > tmp.c: In function ‘foo’: > tmp.c:6:21: error: expected expression before ‘)’ token > > # gcc --version > gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4) > > # sparc-rtems4.11-gcc -Wall -o tmp.o -c tmp.c > tmp.c: In function 'foo': > tmp.c:6:21: error: expected expression before ')' token > > # sparc-rtems4.11-gcc --version > sparc-rtems4.11-gcc (GCC) 4.5.2 20101216 (RTEMS > gcc-4.5.2-3.fc14/newlib-1.19.0-1.fc14) > > > Any explanations? What is wrong?
The code is wrong. sizeof expects either an expression, or a parenthesized type-id. (long) is not a type-id so ((long)) is not a parenthesized type-id, therefore it must be interpreted as an expression, but it's not a valid expression either.