From adc0e91ddbe70c2127d39c337d9b4a09ea752425 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 20 Apr 2021 15:03:43 -0400 Subject: silence GCC warnings --- README.md | 2 +- build.c | 2 +- gl.c | 7 +++++++ math.c | 7 ++++--- syntax.c | 6 ++++-- text.c | 12 ++++++------ 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 726f9b1..b4ad4b3 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ To install `ted` on Linux, you will need: These can be installed on Ubuntu/Debian with: ``` -sudo apt install gcc libsdl2-dev wget unzip cmake +sudo apt install clang libsdl2-dev wget unzip cmake ``` Then run diff --git a/build.c b/build.c index 216c28e..ba85cdd 100644 --- a/build.c +++ b/build.c @@ -160,7 +160,7 @@ static int parse_nonnegative_integer(char32_t **str, char32_t *end) { int n = 0; for (number_len = 0; s != end && s[number_len] >= '0' && s[number_len] <= '9'; ++number_len) { n *= 10; - n += s[number_len] - '0'; + n += (int)s[number_len] - '0'; } if (number_len == 0) return -1; diff --git a/gl.c b/gl.c index a7f720f..8326de6 100644 --- a/gl.c +++ b/gl.c @@ -66,7 +66,14 @@ static int gl_version_minor; static void gl_get_procs(void) { #define gl_get_proc(upper, lower) gl##lower = (PFNGL##upper##PROC)SDL_GL_GetProcAddress("gl" #lower); +#if __GNUC__ && !__clang__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" +#endif gl_for_each_proc(gl_get_proc) +#if __GNUC__ && !__clang__ + #pragma GCC diagnostic pop +#endif #undef gl_get_proc } diff --git a/math.c b/math.c index 42f6cb9..6fa309d 100644 --- a/math.c +++ b/math.c @@ -810,11 +810,12 @@ static u32 color_interpolate(float x, u32 color1, u32 color2) { // to make it interpolate more nicely, convert to hsv, interpolate in that space, then convert back c1 = color_rgba_to_hsva(c1); c2 = color_rgba_to_hsva(c2); - float h1 = c1.x, s1 = c1.y, v1 = c1.z, a1 = c1.w; - float h2 = c2.x, s2 = c2.y, v2 = c2.z, a2 = c2.w; + // v_1/2 named differently to avoid shadowing + float h1 = c1.x, s1 = c1.y, v_1 = c1.z, a1 = c1.w; + float h2 = c2.x, s2 = c2.y, v_2 = c2.z, a2 = c2.w; float s_out = lerpf(x, s1, s2); - float v_out = lerpf(x, v1, v2); + float v_out = lerpf(x, v_1, v_2); float a_out = lerpf(x, a1, a2); float h_out; diff --git a/syntax.c b/syntax.c index 19aca34..56dc15f 100644 --- a/syntax.c +++ b/syntax.c @@ -573,8 +573,10 @@ static void syntax_highlight_python(SyntaxState *state, char32_t const *line, u3 } *state = 0; if (in_string && string_is_multiline) { - *state |= SYNTAX_STATE_PYTHON_STRING - | (SYNTAX_STATE_PYTHON_STRING_DBL_QUOTED * string_is_dbl_quoted); + *state |= (SyntaxState)( + SYNTAX_STATE_PYTHON_STRING + | (SYNTAX_STATE_PYTHON_STRING_DBL_QUOTED * string_is_dbl_quoted) + ); } } diff --git a/text.c b/text.c index 9e9246f..cf951e1 100644 --- a/text.c +++ b/text.c @@ -322,12 +322,12 @@ top: } if (state->render) { float r = state->color[0], g = state->color[1], b = state->color[2], a = state->color[3]; - TextVertex v1 = {{x0, y0}, {s0, t0}, {r, g, b, a}}; - TextVertex v2 = {{x0, y1}, {s0, t1}, {r, g, b, a}}; - TextVertex v3 = {{x1, y1}, {s1, t1}, {r, g, b, a}}; - TextVertex v4 = {{x1, y0}, {s1, t0}, {r, g, b, a}}; - TextTriangle triangle1 = {v1, v2, v3}; - TextTriangle triangle2 = {v3, v4, v1}; + TextVertex v_1 = {{x0, y0}, {s0, t0}, {r, g, b, a}}; + TextVertex v_2 = {{x0, y1}, {s0, t1}, {r, g, b, a}}; + TextVertex v_3 = {{x1, y1}, {s1, t1}, {r, g, b, a}}; + TextVertex v_4 = {{x1, y0}, {s1, t0}, {r, g, b, a}}; + TextTriangle triangle1 = {v_1, v_2, v_3}; + TextTriangle triangle2 = {v_3, v_4, v_1}; arr_add(font->triangles[page], triangle1); arr_add(font->triangles[page], triangle2); } -- cgit v1.2.3