The type:
unsigned long long my_num;
seems cumbersome. I seem to recall seeing a shorthand for it, something like:
ull my_num;
Am I going mad, or is there a simpler way of writing unsigned long long?
The type:
unsigned long long my_num;
seems cumbersome. I seem to recall seeing a shorthand for it, something like:
ull my_num;
Am I going mad, or is there a simpler way of writing unsigned long long?
On
is there a simpler way of writing
unsigned long long(?)
Yes, depending on goal.
First ask why is code using unsigned long long?
Use uintmax_t from <inttypes.h>
If the goal is to use the widest available integer type, then use uintmax_t. uintmax_t and unsigned long long types are at least 64-bit. uintmax_t is the widest available specified integer type and may be wider than unsigned long long.
Use uint64_t from <stdint.h>
If the goal is to use a 64-bit integer type, then use uint64_t. It is exactly 64-bits. unsigned long long may be 64-bits or wider.
Use unsigned long long
If the goal really is to unsigned long long, then use unsigned long long and not a shorthand or some typedef such as typedef unsigned long long ull;. In forming this answer, I did not type unsigned long long, but used copy & paste. unsigned long long is clear. ull is not a universal nor standard substitute for unsigned long long and such shorthands lead to less clear and non-portable code due to name collisions and the need to find the ull typedef to discern if it is as hoped.
There is no type named
ull.ullcan be used as a suffix when specifying an integer constant such as:You can read more about integer constants in the C standard section 6.4.4.1.
If you insist on using
ullas a type name, although I would advise against this*, you can usetypedef:*As others have pointed out there is no clear advantage to using such a shorthand and at the very least it makes the code less readable.