【发布时间】:2026-02-21 11:30:01
【问题描述】:
为什么下面的程序会报错?
#include <stdio.h>
int main()
{
unsigned int64_t i = 12;
printf("%lld\n", i);
return 0;
}
错误:
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
但是,如果我删除 unsigned 关键字,它工作正常。所以,
为什么unsigned int64_t i 会报错?
【问题讨论】:
-
你需要
#include <stdint.h>。您还应该使用uint64_t而不是unsigned int64_t。 -
一旦你包含了正确的头文件,为什么不使用
uint64_t类型呢? -
@PaulR 得到同样的错误。
-
@rsp:你解决了两个问题吗?