Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code in docs produces warning/error #1516

Open
MarkOates opened this issue Nov 29, 2023 · 3 comments
Open

Example code in docs produces warning/error #1516

MarkOates opened this issue Nov 29, 2023 · 3 comments

Comments

@MarkOates
Copy link
Contributor

The following example code for al_draw_prim() will error (with the compile flag -Werror=reorder-ctor):

ALLEGRO_VERTEX v[] = {
   {.x = 128, .y = 0, .z = 0, .color = white, .u = 128, .v = 0},
   {.x = 0, .y = 256, .z = 0, .color = white, .u = 0, .v = 256},
   {.x = 256, .y = 256, .z = 0, .color = white, .u = 256, .v = 256}};

Error message is error: designator order for field does not match declaration order, indicating the order of fields declared here: ALLEGRO_VERTEX, does not match the order of the designators in the example.

In this case the side effect is not consequential, but could be fixed by moving .color = ... to the end of the list.

For some reason I only get this error on gcc (Win) and not clang (Mac).

@pedro-w
Copy link
Contributor

pedro-w commented Nov 29, 2023

What version of compiler? I was messing about with godbolt and I found it was never flagged if I compiled as C, but always a warning with clang in C++ mode and always an error with gcc in C++ mode.

@MarkOates
Copy link
Contributor Author

Looks like this version is gcc version 9.2.0 (Rev2, Built by MSYS2 project). Target is x86_64-w64-mingw32, not sure if that makes a difference.

@ReiquelApplegate
Copy link
Contributor

ALLEGRO_COLOR is all floats, so rearranging the members shouldn't change sizeof(ALLEGRO_VERTEX) either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants