TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Bob Stout
date: 2003-08-12 20:36:08
subject: Re: Bob`s questi

From: rbs{at}snippets.org
To: c_echo{at}yahoogroups.com

On Sun, 10 Aug 2003 Jasen Betts wrote:

>  ac> 12:int moo_size = sizeof moo;
>
>  ac> test.c:12: syntax error before `moo'
>
> int moo_size = sizeof (moo);
> // I see you figured that out in the next message
>
> dunno what the parenthesis do, but they make it work.
>
> (hmmm maybe they turned a type into a typecast)

More from ISO/IEC 9899:1999, sec. 6.5.3.4:

"The sizeof operator yields the size (in bytes) of its operand, which may
be an expression or the parenthesized name of a type."

IOW, whether the parentheses are required depends on the operand. Many
compilers are notorious in their arbitrary enforcement (or non-
enforcement!) of this. It's therefore always safest to use the parentheses
in all cases - even when they might not be *strictly* necessary. Using the
parentheses will always work on all compilers. Not using them may or may
not work, with there being little correlation between the spec and the
specific odds of success.

-------------------------------------------------------------
Consulting: http://www.MicroFirm.biz/
Web graphics development: http://Image-Magicians.com/
Software archives: http://snippets.org/snippets/
Audio and loudspeaker design:
  http://LDSG.snippets.org/
  http://www.diyspeakers.net/

--- SoupGate-Win32 v1.05
* Origin: rbs{at}snippets.org (2:292/516.666)
SEEN-BY: 633/267 270
@PATH: 292/516 854 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.