I believe that the question of how to get a 64-bit integer has received a sufficient answer, but I will take a picture on the second, whether it be "long long" or "__INT64". The question you need to answer first is what you need. If for some reason you need exactly 64 bits, be sure to use something that gives you exactly these 64 bits, i.e. int64_t. Even if your platform / compiler does not have stdint.h, create your typedef as a suitable type as a workaround (# ifdef'd for the compiler), because it makes your code more self-documenting. On the other hand, if you work, for example. offsets in large segments of memory (like a DVD image), use size_t or ssize_t because they usually have the same size as the pointer, which is also self-documenting. Similarly, the offset in the file is best represented using fpos_t.
BTW: the assumption that "long" is 64 bits in Linux is incorrect. In particular, for 32-bit variants it is not 64 bits, and I am also not sure if all 64-bit variants really use 64-bit longs. These different systems are called ILP32, LP64, and LLP64. Search for these terms on the Internet!
source share