char mem[8];
uint64_t *memory{(uint64_t*)(void*)&mem[0]};
std::cout << "diff: " << (void*)memory - (void*)(&mem[0]) << std::endl;
簡單的例子,用gcc錯誤消息是:C++無效使用void,爲什麼?
error: invalid use of ‘void’
std::cout << "diff: " << (void*)memory - (void*)(&mem[0]) << std::endl;
你想做什麼?將'char []'重新解釋爲單個'uint64_t'? – CoryKramer
你不能在'void *'上執行指針運算 – Kevin
@CoryKramer很多時候,試圖將'char []'轉換爲'uint64_t'數組。我認爲這很容易,但這讓我難以置信...... – user3728501