-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use 1u <<
when dealing with Uint32 and Uint16
#9412
Conversation
Helps with generating bindings, as `1u` seems to be platform-agnostic, while `1ul` has platform defined width.
@smcv, are there any other implications of this PR? |
The Source: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.clong?view=net-8.0 |
1u is explicitly unsigned and implicitly 1ul is explicitly unsigned and explicitly If we want a constant that has a fixed size in bits, as far as I'm aware the only way to achieve that is A taxonomy of "normal" platform data models, for reference:
In practice it's rare to have |
This is really two different changes, and I would personally say that they should be two separate commits.
Changing Does SDL document the architectural assumptions that it makes? It might be good to have a document that describes the assumptions that SDL makes beyond the guarantees of Standard C, for example "we (do/don't) assume that int is at least 16 bits in size". I can say with at least 99% confidence that SDL does make some assumptions beyond what Standard C guarantees, because any particular version of Standard C is less helpful than you would think! GLib has https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md?ref_type=heads which is the sort of thing that I'm thinking of: it documents GLib as requiring about half of the differences between C89 and C99. Another good way to document architectural assumptions is with static assertions, like |
Most of this was added in #9726. |
Description
Changes
#define
s which define constants commonly used with unsigned integers to use1u << x
instead of1 << x
or1ul << x
.Helps with generating bindings, as
1u
seems to be platform-agnostic, while1ul
has platform defined width (at least when using ClangSharp on windows).Main inspiration is
SDL_haptic.h
definitions (of whichSDL_HAPTIC_SQUARE
was missed!)