Improve C standard compliance. - #96
Merged
Merged
Conversation
iphydf
force-pushed
the
compliance
branch
2 times, most recently
from
September 5, 2016 22:03
9c870c5 to
6c74f12
Compare
Member
|
Reviewed 13 of 13 files at r1. Comments from Reviewable |
Member
|
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Member
|
Reviewed 12 of 13 files at r1, 1 of 1 files at r2. Comments from Reviewable |
|
Reviewed 12 of 13 files at r1, 1 of 1 files at r2. Comments from Reviewable |
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
Folding integral constants like that as compile time constants is a GNU
extension. Arrays allocated with `foo` as dimension are VLAs on strictly
compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
object pointer can be implicitly converted to and from `void *`, this
conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
`short`-derived) in bit fields with `int`-derived types. Using any type
other than `int` or `unsigned int` (or any of their aliases) in bit
fields is a GNU extension.
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
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.
__VA_ARGS__in macros.__extension__on unnamed union in struct (it's a GNUextension).
const T foo = 3;for integral typesTwithenum { foo = 3 };.Folding integral constants like that as compile time constants is a GNU
extension. Arrays allocated with
fooas dimension are VLAs on strictlycompliant C99 compilers.
{}with zero-initialiser-list{0}.The former is a GNU extension meaning the latter.
T*(whereT != void) tovoid *in format arguments. While anyobject pointer can be implicitly converted to and from
void *, thisconversion does not happen in variadic function calls.
void *with arithmetic onchar *. The formeris non-compliant.
int-derived types (likeuint16_t, which isshort-derived) in bit fields withint-derived types. Using any typeother than
intorunsigned int(or any of their aliases) in bitfields is a GNU extension.
This change is