Skip to content

Structure s_color4 members alignment problem #26

Description

@vinz6751

"types.h" defines the following structure to represent a 32 bit color:

typedef struct s_color4 {
    uint8_t blue;
    uint8_t green;
    uint8_t red;
    uint8_t alpha;
} t_color4;

I suspect that VBCC will align structure members on word or long word boundaries. So if you want to align the members on bytes instead (so the whole structure is 4 bytes), you should wrap the declaration with:

#pragma pack(1)
typedef struct s_color4 {
...
} t_color4;
#pragma pack()

as indicated on page 46 of the VBCC manual.
I haven't tested it though

It struck me because for the EmuTOS port I had the problem and had to use the packed attribute to indicate what I wanted to GCC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions