diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-12-05 00:00:42 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-12-05 00:00:42 -0500 |
commit | a7c1f9727a099da0d4722d4cf81056acd205158b (patch) | |
tree | 90e1c64185cab587af89001e658d039821204a0e /include | |
parent | b427c822655156f17d17cd00110ff5bc22299a38 (diff) | |
download | musl-a7c1f9727a099da0d4722d4cf81056acd205158b.tar.gz musl-a7c1f9727a099da0d4722d4cf81056acd205158b.tar.bz2 musl-a7c1f9727a099da0d4722d4cf81056acd205158b.tar.xz musl-a7c1f9727a099da0d4722d4cf81056acd205158b.zip |
use __builtin_offsetof to implement offsetof when possible
apparently recent gcc versions have intentionally broken the
traditional definition by treating it as a non-constant expression.
the traditional definition may also be problematic for c++ programs.
Diffstat (limited to 'include')
-rw-r--r-- | include/stddef.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/stddef.h b/include/stddef.h index dbf5a4ae..a5bb9ecc 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -14,6 +14,10 @@ #include <bits/alltypes.h> +#if __GNUC__ > 3 +#define offsetof(type, member) __builtin_offsetof(type, member) +#else #define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 )) +#endif #endif |