Skip to content

Conversation

adriaandegroot
Copy link
Contributor

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.

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.
@adriaandegroot
Copy link
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 no_args_please() form obsolescent.

@evanmiller
Copy link
Contributor

Thanks!

@evanmiller evanmiller merged commit 5ad8004 into WizardMac:dev Feb 19, 2023
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.

2 participants