ctypessyntaxunsignedunsigned-long-long-int

Is there a shorthand for the unsigned long long type?


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?


Solution

  • There is no type named ull. ull can be used as a suffix when specifying an integer constant such as:

    unsigned long long my_num = 1ull;
    

    You can read more about integer constants in the C standard section 6.4.4.1.

    If you insist on using ull as a type name, although I would advise against this*, you can use typedef:

    #include <stdio.h>
     
    typedef unsigned long long ull;
    int main() {
        ull a = 20ull;
        printf("%llu\n", a);
    }
    

    *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.