TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JAMIE KOWINSKY
from: JERRY COFFIN
date: 1997-10-30 23:05:00
subject: sizeof() question

On (29 Oct 97) Jamie Kowinsky wrote to All...
 JK> long studentsize;
 JK> StudentType temp;
 JK> studentsize = sizeof(temp);
 JK> however i recently found out that I can simply do studentsize =
 JK> sizeof(StudentType);  Well at least in Turbo C++ 4.5 one can, I don't
 JK> know if this is standard.
Yes, it is.
 JK> Now my question is, does the compiler treat "sizeof(StructName);" as a
 JK> constant?  During compile time will it lookup the size of the stuct
 JK> and simply use that number instead of calculating the size of the
 JK> stucture each time?
With nearly all compilers it's handled entirely at compile time.  I
believe Metaware supports some extensions so under some circumstances
it's done at run-time, but this is _quite_ unusual.
    Later,
    Jerry.
--- PPoint 2.02
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

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™.