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

Improve C standard compliance. #96

Merged
merged 1 commit into from Sep 6, 2016
Merged

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Sep 5, 2016

  • 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 change is Reviewable

@iphydf iphydf force-pushed the compliance branch 2 times, most recently from 9c870c5 to 6c74f12 Compare Sep 5, 2016
@nurupo
Copy link
Member

nurupo commented Sep 5, 2016

Reviewed 13 of 13 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Sep 5, 2016

:lgtm_strong:


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@JFreegman
Copy link
Member

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@iphydf iphydf unassigned tux3 Sep 6, 2016
@GrayHatter
Copy link

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


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.
@iphydf iphydf closed this Sep 6, 2016
@iphydf iphydf merged commit 5b57ab6 into TokTok:master Sep 6, 2016
@iphydf iphydf deleted the compliance branch Sep 6, 2016
@iphydf iphydf modified the milestone: v0.0.1 Nov 6, 2016
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.

None yet

5 participants