-1
我使用SDL2的遊戲項目,當我試圖將值分配給一個變量UINT32,編譯器將拋出這個錯誤:如何爲Uint32變量賦值?
int sdl_create_win(t_render *ress, t_map *map)
{
SDL_CreateWindowAndRenderer(WIN_X, WIN_Y, 0, &ress->screen, &ress->rend);
if (!ress->screen || !ress->rend)
{
fprintf(stderr,
"Problem encountered while creating windows -> SDL Error : %s\n",
SDL_GetError());
SDL_Quit();
return (-1);
}
ress->texture = SDL_CreateTexture(ress->rend,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STATIC,
map->x, map->y);
ress->pixels = [map->x * map->y];
memset(ress->pixels, 255, map->x * map->y * sizeof(Uint32));
return (0);
}
編譯器錯誤是 - >
30:18: error: expected expression before ‘[’ token
ress->pixels = [map->x * map->y];
謝謝很多幫助!
什麼是Uint32?爲什麼不使用標準的固定寬度類型?錯誤與類型無關,但與您的冒險 - 語法無關。它根本就不是C. – Olaf
表達式'map-> x * map-> y'應該做些什麼?''和'''方括號是什麼?也許你需要[找到一個好的初學者書](http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list)? –