how to use uint64_t in C [duplicate]

#include <stdio.h>
#include <stdint.h>

int main(){
    uint64_t a = 1 << 63;
    /* do some thing */
    return 0;
}

$ gcc -Wall -Wextra -std=c99 test.c -o test  
warning: left shift count >= width of type [-Wshift-count-overflow]

Q: uint64_t should have 64 bits width, why the left shift operation overflows?

Leave a Comment