I am using SDL2 for a game project and when i am trying to assign a value to a Uint32 variable, compiler throws this error :
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);
}
compiler error is -->
30:18: error: expected expression before ‘[’ token
ress->pixels = [map->x * map->y];
Thanks a lot for help !!
DS looks fine, Uint32 is a valid type in SDL.
If this syntax is supposed to be C, the error is ress->pixels = [map->x * map->y];
.
Square brackets are not a part of the syntax when used that way.
Perhaps you should state what you want to accomplish by that line?