Skip to content

Commit

Permalink
compiler.h: Remove extra parentheses in call to memberof()
Browse files Browse the repository at this point in the history
When switching to `-nostdinc -nostdlib` we are going to start using local
defintions of those macros that we apparently did not use before. I found a bug
in the implementation of `offsetof` that leads to a compile time error and is
fixed by removing the parentheses around the type parameter.

Signed-off-by: Bjoern Doebel <[email protected]>
  • Loading branch information
bjoernd authored and wipawel committed Nov 20, 2020
1 parent 129a893 commit 138dd3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef uint64_t off_t;

#define memberof(type, member) (((type *) 0)->member)
#ifndef offsetof
#define offsetof(type, member) ((off_t) &memberof((type), member))
#define offsetof(type, member) ((off_t) &memberof(type, member))
#endif

#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" STR(cond) ")"); })
Expand Down

0 comments on commit 138dd3f

Please sign in to comment.