-
Notifications
You must be signed in to change notification settings - Fork 254
Some improvements to type-safe macros #1388
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8810753 to
e6d4df2
Compare
2b2ad57 to
01221f1
Compare
529d0c2 to
eb1e883
Compare
24b641c to
ed5996d
Compare
Signed-off-by: Alejandro Colomar <[email protected]>
Casts are unsafe. Compound literals also have the ability of converting values, but they don't have the unwanted effects on safety --casts disable most useful diagnostics--. Compound literals are lvalues, which means their address can be taken, and they can also be assigned to. To avoid this, we force lvalue conversion through a statement expression. Signed-off-by: Alejandro Colomar <[email protected]>
This should be more readable. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar <[email protected]>
We don't use this value. This silences a diagnostic about the unused return value. Signed-off-by: Alejandro Colomar <[email protected]>
hallyn
approved these changes
Dec 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cc: @uecker , @thradams
Revisions:
v2
interdiff
range-diff
v3
v4
v5
I have plans for these macros for the future, and this will make it easier to apply those.
interdiff
range-diff
v5b
v6
registerto not allow accidentally taking the address of compound literals.v7
register, which would also needconstto prevent assignment. It's non-standard, but we're okay with that. If one would want write portable code,register constcompound literals would be okay.register constthing to avoid lvalue issues, and results in more readable code, as each check can go in a separate line.v8
interdiff
range-diff
v8b
v8c
v9
v9b
v10
v10b
v11
(void)0to avoid-Wunused-valuediagnostics.v11b