32 printed by the C program means 32 bytes. Given that the array contains 8 elements and each element is 4 bytes, 32 = 8 * 4.
In C, for (complete) arrays, sizeof gives the number of bytes occupied by the whole array. If memory occupied by a pointer is of interest instead, either &a should be used, or a pointer type rather than an array type.
In particular,
sizeof &a
gives 8 (for variables there is no need to use parentheses, i.e. to write "sizeof (&a)", they are required when the argument is a type, not a variable).
If we had
extern const int x [];
const int * y;
the results would be
sizeof x -- 0 and the compiler raises a warning for me, because the array size is unknown to the compiler (the array type in incomplete)
sizeof y -- 8
To summarize, the pointer size obtained by "{PLATFORM}.pointer_bytes" or by "sizeof &a" is the same.
Alexander Kogtenkov
Chris Tillman <toff.t...@gmail.com>: