为什么"unsigned int64_t"在C中出错?

msc*_*msc 2 c unsigned gcc int64

为什么以下程序出错?

#include <stdio.h>

int main() 
{
    unsigned int64_t i = 12;
    printf("%lld\n", i);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

错误:

 In function 'main':
5:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i'
  unsigned int64_t i = 12;
                   ^
5:19: error: 'i' undeclared (first use in this function)
5:19: note: each undeclared identifier is reported only once for each function it appears in
Run Code Online (Sandbox Code Playgroud)

但是,如果我删除unsigned关键字,它工作正常.那么, 为什么unsigned int64_t i会出错呢?

eml*_*lai 12

您无法unsigned在类型上应用修改器int64_t.它仅适用于char,short,int,long,和long long.

你可能想要使用uint64_t哪个是无符号的对应物int64_t.

另请注意int64_t等.在标题中定义,stdint.h如果要使用这些类型,则应包括该标题.


Mis*_*cha 6

int64_t不是一些内置类型.尝试添加#include <stdint.h>以定义此类型; 然后使用uint64_t这意味着你想要的东西.心连心