lib: Use offsetof() builtin with GCC
The default offsetof() implementation generates a warning (variably modified <variable> at file scope) when used in to define the size of an array. By using this builtin with GCC we avoid the warning and make sure no variable-size arrays are used. Change-Id: Iae215f777241f7daaa061067230086dffaa8311d Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
72f00d930e
commit
1980b7bb0f
|
@ -27,6 +27,10 @@
|
|||
typedef int ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
#else
|
||||
#define offsetof(type, member) ((size_t) (&((type *) NULL)->member))
|
||||
#endif
|
||||
|
||||
#endif /* __INC_stddef_h__ */
|
||||
|
|
Loading…
Reference in a new issue