Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:24:20+00:00 2026-05-30T01:24:20+00:00

How do I go about avoiding the compiler warning (warning: cast increases required alignment

  • 0

How do I go about avoiding the compiler warning (warning: cast increases required alignment of target type) in the following code?

static int fill_color24 (VisVideo *video, VisColor *color)
{
    int x, y;
    uint32_t *buf;
    uint8_t *rbuf = visual_video_get_pixels (video);
    uint8_t *buf8;

    int32_t cola =
        (color->b << 24) |
        (color->g << 16) |
        (color->r << 8) |
        (color->b);
    int32_t colb =
        (color->g << 24) |
        (color->r << 16) |
        (color->b << 8) |
        (color->g);
    int32_t colc =
        (color->r << 24) |
        (color->b << 16) |
        (color->g << 8) |
        (color->r);

    for (y = 0; y < video->height; y++) {
        buf = (uint32_t *) rbuf; // warning is for this line

        for (x = video->width; x >= video->bpp; x -= video->bpp) {
            *(buf++) = cola;
            *(buf++) = colb;
            *(buf++) = colc;
        }

        buf8 = (uint8_t *) buf;
        *(buf8++) = color->b;
        *(buf8++) = color->g;
        *(buf8++) = color->r;


        rbuf += video->pitch;
    }

    return VISUAL_OK;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:24:21+00:00Added an answer on May 30, 2026 at 1:24 am

    I’m not sure you can. That function might return color array unaligned. You can’t do anything to be able to read word from there.
    You will have to read color by components (uint8_t) and then construct uint32_t from these by adding and shifting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To be specific, I'm talking about avoiding this type of code: <input type='text' id='title_33'
Thinking about avoiding code replication, I got a question that catches me every time
My question is about avoiding namespace pollution when writing modules in R. Right now,
I seem to recall something about avoiding the Immediate If operator ( ?: )
I've read a few other posts like this one about avoiding repetition in Java
I read the Avoiding Memory Leaks article with interest, and am concerned about danging
I've recently seen some information about avoiding coding to specific browsers an instead using
I found comments about avoiding strings for the comparison of values (especially in loops)
I have asked a question about how to avoiding to write the html in
I am curious about how the following concepts typically execute inside a Java EE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.