我收到「訪問衝突讀取位置0x0000000000000008」。與此代碼:結構
main.xcpp
Penguin::Game game;
game.memory = {};
game.memory.permanentSize = 1024*64;
game.memory.permanent = VirtualAlloc(0, game.memory.permanentSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
game.Start();
game.Start()
input = (Input *)memory.permanent;
*input = {}; // << Access violation reading location.
遊戲結構
struct Game
{
struct Memory
{
uint64 permanentSize;
void *permanent;
};
Memory memory;
Input *input;
void Start();
};
不過。如果我嘗試:
int *i = (int *)memory.permanent;
*i = 10;
它的工作原理。
我在做什麼錯了?
你有一個調試器,學習如何使用它! –