Skip to content

begin_code: Added SDL_ALIGNED macro. #13132

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

Merged
merged 1 commit into from
May 27, 2025
Merged

Conversation

icculus
Copy link
Collaborator

@icculus icculus commented May 27, 2025

I'm running into places where I want to define data that is aligned for SSE or NEON access, so being able to tell the compiler "this struct (or struct member) needs to be aligned to 16 bytes" or "this stack variable needs to be aligned" becomes essential.

All compilers supporting C11 or C++11 support a keyword for this, and GCC/Clang/MSVC all have their own syntax to handle it, long before those standards.

I'm torn about what to do on compilers that don't support it (which is...possible no significant compilers). Seeing as they will definitely miscompile code in that case, I have it intentionally generate an error; the docs currently say it the macro defined in this case, the code currently defines it to something like an error message. It's not clear to me which approach is better, or if defining it to nothing is better to let the compiler roll the dice.

@icculus icculus added this to the 3.4.0 milestone May 27, 2025
@icculus icculus requested a review from slouken May 27, 2025 16:03
@icculus icculus self-assigned this May 27, 2025
@icculus icculus force-pushed the sdl3-sdl_aligned branch from a42a71d to 69f95df Compare May 27, 2025 16:35
@icculus icculus merged commit 3940c66 into libsdl-org:main May 27, 2025
41 checks passed
@icculus icculus deleted the sdl3-sdl_aligned branch May 27, 2025 17:30
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

Successfully merging this pull request may close these issues.

2 participants