comp.lang.c
[Top] [All Lists]

Re: sizeof(x)

Subject: Re: sizeofx
From: Harald van Dijk
Date: Sun, 30 Mar 2008 22:15:42 +0200
Newsgroups: comp.lang.c

On Sun, 30 Mar 2008 23:11:55 +0300, Ioannis Vranos wrote:
> Ian Collins wrote:
>> Ioannis Vranos wrote:
>>> Ioannis Vranos wrote:
>>>> I first saw that only sizeof x is valid at the pdf hosted at
>>>> http://cprog.tomsweb.net.
>>>
>>> More specifically the above writes:
>>>
>>> "sizeof      Returns size of operand in bytes; two forms:
>>>                               1) sizeof(type)
>>>                               2) sizeof expression"
>>>
>>>
>> Did you read what Harald said: "(x) is a perfectly valid expression"?
> 
> ... right. However sizeofx doesn't compile and if (x) was considered an
> expression it should be sizeof (x), and sizeof(x) shouldn't compile.

sizeofx doesn't compile because there's no sizeof operator. There's a 
sizeofx identifier. sizeof(x) does and should compile because sizeof( is 
not a valid identifier. This is the same reason why a+++++b is not valid,
but a+++--b is: the first is split into {a}{++}{++}{+}{b}, and the second 
is split into {a}{++}{+}{--}{b}.

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy