Skip to content

Commit

Permalink
hash: fix build failure against gcc-10
Browse files Browse the repository at this point in the history
On gcc-10 (and gcc-9 -fno-common) build fails as:

```
gcc  -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes \
  -Wmissing-declarations -Wredundant-decls   -o memcached ... -levent
ld: memcached-hash.o:memcached/hash.h:5:
  multiple definition of `hash'; memcached-memcached.o:memcached/hash.h:5: first defined here
```

gcc-10 will change the default from -fcommon to fno-common:
https://gcc.gnu.org/PR85678.

The error also happens if CFLAGS=-fno-common passed explicitly.

Reported-by: Brian Evans
Bug: https://bugs.gentoo.org/706196
Signed-off-by: Sergei Trofimovich <[email protected]>
  • Loading branch information
Sergei Trofimovich authored and dormando committed Feb 1, 2020
1 parent 32bf2c3 commit 0447ae4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "jenkins_hash.h"
#include "murmur3_hash.h"

hash_func hash;

int hash_init(enum hashfunc_type type) {
switch(type) {
case JENKINS_HASH:
Expand Down
2 changes: 1 addition & 1 deletion hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define HASH_H

typedef uint32_t (*hash_func)(const void *key, size_t length);
hash_func hash;
extern hash_func hash;

enum hashfunc_type {
JENKINS_HASH=0, MURMUR3_HASH
Expand Down

0 comments on commit 0447ae4

Please sign in to comment.