如何为Uint32变量赋值?

时间:2016-06-20 13:35:40

标签: c sdl uint32

我正在将SDL2用于游戏项目,当我尝试为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];

非常感谢你的帮助!!

1 个答案:

答案 0 :(得分:2)

DS看起来很好,Uint32是SDL中的有效类型。

如果此语法应为C,则错误为ress->pixels = [map->x * map->y];

使用这种方式时,方括号不是语法的一部分。

也许你应该说明你想要通过那条线完成什么?