Is "(int)" in "sizeof (int)" a type operator or some special case parameter? [FROM]
I've always assumed that a C expression sizeof (int)
works like a function, with everything inside the parentheses being passed as a parameter. Since int
(or any other type specifier) ββis actually a keyword and not an object that can be passed around, I assumed it was just some kind of special case hard-coded into the compilers.
But I recently discovered that if I use sizeof
for a variable, I can omit the parentheses ( sizeof var
) and it will compile and work fine. Since sizeof
it is actually the operator itself, not a function (and the operators don't need parentheses) and the type specifiers are the only things that need the parentheses, now I'm wondering if they are really type specifiers, re is actually the type of operators -operators, which are somehow used sizeof
to find sizes for matching types.
source to share