On 01/31/2011 10:19 AM, Jonathan Wakely wrote:
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.
It's code GCC's configure scripts apply.
AFAICT, these fragments seems to originate from autoconf and don't have
seem to cause any harm (but confusing the reader of config.logs).
ATM, I am not sure, if what autoconf does actually is useful, but this
is a different matter.
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.
Thanks for the explanation.
Ralf