Skip to content

Commit

Permalink
Add strict prototypes for functions with no arguments. (#295)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adriaandegroot authored Feb 19, 2023
1 parent 6bb297c commit 5ad8004
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/readstat_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef READSTAT_MACHINE_IS_TWOS_COMPLEMENT
#define READSTAT_MACHINE_IS_TWOS_COMPLEMENT 0

int machine_is_little_endian();
int machine_is_little_endian(void);

char ones_to_twos_complement1(char num);
int16_t ones_to_twos_complement2(int16_t num);
Expand Down
2 changes: 1 addition & 1 deletion src/readstat_variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdlib.h>
#include "readstat.h"

static readstat_value_t make_blank_value();
static readstat_value_t make_blank_value(void);
static readstat_value_t make_double_value(double dval);

static readstat_value_t make_blank_value() {
Expand Down
2 changes: 1 addition & 1 deletion src/sas/ieee.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void ieee2xpt(unsigned char *ieee, unsigned char *xport);

#ifndef FLOATREP
#define FLOATREP get_native()
int get_native();
int get_native(void);
#endif

void memreverse(void *intp_void, int l) {
Expand Down
2 changes: 1 addition & 1 deletion src/spss/readstat_por.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct por_ctx_s {
ck_hash_table_t *var_dict;
} por_ctx_t;

por_ctx_t *por_ctx_init();
por_ctx_t *por_ctx_init(void);
void por_ctx_free(por_ctx_t *ctx);
ssize_t por_utf8_encode(const unsigned char *input, size_t input_len,
char *output, size_t output_len, uint16_t lookup[256]);
Expand Down

0 comments on commit 5ad8004

Please sign in to comment.