Question

As we can see a macro defined in stdint.h or bits/types.h etc.. which is __WORDSIZE. I don't know where to check out whether this macro is defined. Also, is there a way to checkout different size of the basic types without using the sizeof in c. I mean, is there a document exhibits the size of those variables?

Was it helpful?

Solution

Well, it depends on the platform. First, there are some requirements set by the C standard and/or the POSIX standard if you use UNIX. Things like sizeof(int) <= sizeof(long) or sizeof(char) == 1

Then the ABI has the final say. For example, on linux/freebsd/solaris on x86_64, they use a common ABI: http://people.freebsd.org/~obrien/amd64-elf-abi.pdf

3.1.2 in this document has the size for all types for this ABI

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top