Skip to content

Commit

Permalink
Replace inline to static to resolve compiler issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kien Phung committed Oct 15, 2018
1 parent e338bd0 commit 8c0dc8f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/bitset/bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ static VALUE rb_bitset_equal(VALUE self, VALUE other) {
}

typedef uint64_t (*bitwise_op)(uint64_t, uint64_t);
inline uint64_t and(uint64_t a, uint64_t b) { return a & b; }
inline uint64_t or(uint64_t a, uint64_t b) { return a | b; }
inline uint64_t xor(uint64_t a, uint64_t b) { return a ^ b; }
inline uint64_t difference(uint64_t a, uint64_t b) { return a & ~b; }
static uint64_t and(uint64_t a, uint64_t b) { return a & b; }
static uint64_t or(uint64_t a, uint64_t b) { return a | b; }
static uint64_t xor(uint64_t a, uint64_t b) { return a ^ b; }
static uint64_t difference(uint64_t a, uint64_t b) { return a & ~b; }

static VALUE mutable(VALUE self, VALUE other, bitwise_op operator) {
Bitset * bs = get_bitset(self);
Expand Down

1 comment on commit 8c0dc8f

@denizevrenci-quoine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some information about the issue:
https://gcc.gnu.org/gcc-5/porting_to.html
https://bugzilla.redhat.com/show_bug.cgi?id=1494052

I suppose the version of GCC used up to now was 4.X.X. Thus it had the earlier GNU89 inline semantics (C89 did not have the keyword inline at all). While GCC versions after 5.0.0 use C99 semantics, which does not produce an out of line definition for the function. I suppose the reason is that this code uses function pointers which somehow does not let the functions inlined and the code produced by the compiler expects definitions from an external translation unit.

Please sign in to comment.