Wie kann man int64_t / uint64_t Konstanten eingeben?

Ich versuche, eine Konstante zu definieren, die 2 ^ 30 entspricht (ich kann sie in 2 ^ 34 ändern, also bevorzuge ich einen Raum, der größer als 32 Bit ist).

Warum wird das folgende minimale (?) Beispiel nicht kompiliert?

#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; }

Antworten auf die Frage(3)

Ihre Antwort auf die Frage