( uid_2716 | 2011. 04. 27., sze – 13:25 )

Valami vérgagyi fordítón lehet belőle kód konstans helyett

Sehol sem lehet. ISO C99 "6.5.3.4 The sizeof operator":


  Semantics

2 The sizeof operator yields the size (in bytes) of its operand, which may be an
  expression or the parenthesized name of a type. The size is determined from the type of
  the operand. The result is an integer. If the type of the operand is a variable length array
  type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an
  integer constant.

Egy példa az "integer constant"-ra:

12

.

Gyakorlati oldalról megközelítve: ha a sizeof nem értékelődne ki fordítási időben (VLA-kat most félretéve), akkor lehetetlen volna használni például struct-ok és egyéb típusok definíciójában.