相关疑难解决方法(0)

如何输入int64_t/uint64_t常量?

我要做的是定义一个等于2 ^ 30的常量(我可能会将它改为2 ^ 34,所以我更喜欢有一个大于32位的空间).

为什么下面的最小(?)示例不能编译?

#include <stdint.h>
// test.cpp:4:33: error: expected primary-expression before numeric constant
// test.cpp:4:33: error: expected ')' before numeric constant
const uint64_t test = (uint64_t 1) << 30;
//const uint64_t test1 = (uint64_t(1)) << 30;// this one magically compiles! why?

int main() { return 0; }
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors const g++ int64

7
推荐指数
3
解决办法
2万
查看次数

标签 统计

c++ ×1

compiler-errors ×1

const ×1

g++ ×1

int64 ×1