MACRO
OMNI_SIZEOF_BITS - Gets the sizeof a type in bits
DESCRIPTION top
This macro is defined as the following:
Where
Example:
Output on a 32-bit x86 system:
Output on a 64-bit x86 system:
This macro is defined as the following:
#define OMNI_SIZEOF_BITS(T) (sizeof(T) * CHAR_BIT)
T is the type to get the size of.Example:
#define printv(v) std::cout << #v << " = " << v << std::endl printv(OMNI_SIZEOF_BITS(char*)); printv(OMNI_SIZEOF_BITS(unsigned int)); printv(OMNI_SIZEOF_BITS(unsigned long)); printv(OMNI_SIZEOF_BITS(double));
OMNI_SIZEOF_BITS(char*) = 32
OMNI_SIZEOF_BITS(unsigned int) = 32
OMNI_SIZEOF_BITS(unsigned long) = 32
OMNI_SIZEOF_BITS(double) = 64
Output on a 64-bit x86 system:
OMNI_SIZEOF_BITS(char*) = 64
OMNI_SIZEOF_BITS(unsigned int) = 32
OMNI_SIZEOF_BITS(unsigned long) = 32
OMNI_SIZEOF_BITS(double) = 64
CONSIDERATIONS top
This macro is not affected by the platform architecture (i.e.
This macro is not affected by the platform architecture (i.e.
x86 vs. x86_64 etc.)
PLATFORM SPECIFIC top
The size of the type is multiplied by
The size of the type is multiplied by
CHAR_BIT to get the number of bits representative of a byte on the specific platform (usually CHAR_BIT is 8). If you rely on the size of the bits to be a specific size, you will need to take note of this.