On 64-bit Linux systems I think it can depend on the installation. I have used gcc on a 64-bit Linux PC where "long" was still just 32 bits (which I hadn't expected). I agree that it makes more sense for it to be 64 bits on a 64-bit platform, but I don't think you can depend on that. I think it's generally preferred to include <stdint.h>, then use uint64_t for unsigned 64-bit integers. There's also uint_least64_t (small, >= 64 bits) and uint_fast64_t (fast, >= 64 bits). Tom Joerg Arndt writes:
* Tom Karzes <karzes@sonic.net> [Mar 29. 2014 08:31]:
No, in gcc a "long" is 32-bits.
Not on a 64 bit system.
That's why they introduced "long long", to support a 64-bit integer type without introducing compatibility problems or new keywords.
... on 32 bit systems.
(Sadly "long long" was _not_ promoted to 128 bits on any 64 bit system, bad!).
The C standard requires only that "long" be at least 32 bits. At this point I would say gcc is the de facto reference implementation of C, and I would hardly call its creators imbeciles.
I was talking about a certain Redmond based platform (requiring "unsigned long long" to get a full CPU register).
The C standard mandates that char <= short <= int <= long <= long long and minimum ranges (yes, long >= 32 bit by that), see http://stackoverflow.com/questions/589575/size-of-int-long-etc
Tom
[...]
Best regards, jj