Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

13
Apr

Why sizeof is an operator, not a function?

Related Blog Items

To calculate the size of an object, we need the type information.
This type information is available only at compile time.  At the
end of the compilation phase, the resulting object code doesn’t
have (or not required to have) the type information.

Of course, type information can be stored to access it at run-time,
but this results in bigger object code and less performance.  And
most of the time, we don’t need it.

All the runtime environments that support run time type
identification (RTTI) will retain type information even after
compilation phase.  And if, something can be done in compilation
time itself, why do it at run time?

More importantly, HOW can it be a function when the operand is a
type, not an expression. Even expressions subject to integral
promotion are problematic.

Popularity: 7%

You need to log on to convert this article into PDF


Related Blog Items

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image