Add strict prototypes for functions with no arguments.#295
Merged
evanmiller merged 1 commit intoWizardMac:devfrom Feb 19, 2023
Merged
Add strict prototypes for functions with no arguments.#295evanmiller merged 1 commit intoWizardMac:devfrom
evanmiller merged 1 commit intoWizardMac:devfrom
Conversation
Using compile flags `-Werror -Wstrict-prototypes` (with Clang at least), the "prototypes" of some functions are flagged as an error. This is because of the difference between: ``` int no_args_please(void); ``` and ``` int no_args_please(); ``` Where the former is a strict prototype that says "no arguments are allowed". With the compile flags mentioned, ReadStat fails to compile with error messages like this: ``` In file included from src/readstat_bits.c:9: src/readstat_bits.h:10:29: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] int machine_is_little_endian(); ``` This PR adds the missing `void` in a handful of places where Clang complains about it with those strict compile flags.
Contributor
Author
|
As packager for ReadStat on FreeBSD, I have added these patches to the packaging-bits to make it compile on FreeBSD 14-CURRENT (which defaults to Clang + strict flags). I have not tested with other compilers, but the semantic difference between the two "prototypes" has been relevant since before C11 and apparently C11 makes the |
Contributor
|
Thanks! |
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.
Using compile flags
-Werror -Wstrict-prototypes(with Clang at least), the "prototypes" of some functions are flagged as an error. This is because of the difference between:and
Where the former is a strict prototype that says "no arguments are allowed". With the compile flags mentioned, ReadStat fails to compile with error messages like this:
This PR adds the missing
voidin a handful of places where Clang complains about it with those strict compile flags.