From a48416ef8179faa6e40df1355cd9c613af8382f6 Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Thu, 7 Mar 2024 22:08:03 +0800 Subject: [PATCH] fix compile error with clang in MacOS --- src/keyboard.cpp | 4 ++-- src/term.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/keyboard.cpp b/src/keyboard.cpp index f458d82..cdaabf5 100644 --- a/src/keyboard.cpp +++ b/src/keyboard.cpp @@ -98,7 +98,7 @@ static SDL_Texture* gen_key_texture(SDL_Renderer *renderer, const char *desc1, uint32_t color_dn = SDL_MapRGBA(key_shape->format, 0xc0, 0xc0, 0xc0, 0xff); SDL_Surface *s = surdup(key_shape, is_down ? color_dn : color_up); SDL_Surface *s_desc = str2surface(desc.c_str(), 0); - SDL_Rect r = { .x = 1, .y = 1 }; + SDL_Rect r = (SDL_Rect) { .x = 1, .y = 1 }; SDL_BlitSurface(s_desc, NULL, s, &r); SDL_Texture *t = SDL_CreateTextureFromSurface(renderer, s); SDL_FreeSurface(s_desc); @@ -111,7 +111,7 @@ static void init_key_texture(SDL_Renderer *renderer, uint8_t sdl_key, Key *e = &keys[sdl_key]; e->t_up = gen_key_texture(renderer, desc1, desc2, key_shape, false); e->t_down = gen_key_texture(renderer, desc1, desc2, key_shape, true); - e->rect = { .x = x, .y = y, .w = key_shape->w, .h = key_shape->h }; + e->rect = (SDL_Rect){ .x = x, .y = y, .w = key_shape->w, .h = key_shape->h }; } static void init_render_local(SDL_Renderer *renderer) { diff --git a/src/term.cpp b/src/term.cpp index fea6069..25587a3 100644 --- a/src/term.cpp +++ b/src/term.cpp @@ -3,7 +3,7 @@ Term::Term(SDL_Renderer *r, int x, int y, int w, int h): renderer(r), cursor_x(0), cursor_y(0), screen_y(0) { - region = { .x = x, .y = y, .w = w, .h = h }; + region = (SDL_Rect){ .x = x, .y = y, .w = w, .h = h }; w_in_char = region.w / CH_WIDTH; h_in_char = region.h / CH_HEIGHT; uint8_t *l = add_line();