size_t
is a data type that is able to represent the size of any object.
64-bits usually refers to the fact that 64 bits are available to address virtual memory. In C, memory is addressed using pointers. As such, sizeof(void*)
seems to be more adequate to test for 64-bit environment.
However, this is not guaranteed by the C standard. There might be obscure cases where no safe and reliable way to determine the hardware architecture using C exists.
Because sizeof
returns the size as multiples of the size of a char
, you might want to look at CHAR_BIT
(defined in limits.h) to see how many bits there are in a char.