我要做的是定义一个等于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)