SDL SetRenderDrawColor uint8

hello ,

I can’t complicate it

src-zig/Zcons.zig:111:33: error: value of type ‘c_int’ ignored
c.SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);

// /**
 // * The bits of this structure can be directly reinterpreted as an
 // * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format
 // * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and
 // * SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
 // */
// typedef struct SDL_Color
// {
    // Uint8 r;
    // Uint8 g;
    // Uint8 b;
    // Uint8 a;
// } SDL_Color;


         var color : c.SDL_Color = undefined;
         color.r = 0;
         color.g = 0;
         color.b = 0;
         color.a = 255;
        c.SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);

Zig requires that all return values are handled, and c.SDL_SetRenderDrawColor returns a c_int. If you wish to ignore it, then just assign it to _ as such:

_ = c.SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
5 Likes