projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b427c82
)
use __builtin_offsetof to implement offsetof when possible
author
Rich Felker
<dalias@aerifal.cx>
Wed, 5 Dec 2012 05:00:42 +0000
(
00:00
-0500)
committer
Rich Felker
<dalias@aerifal.cx>
Wed, 5 Dec 2012 05:00:42 +0000
(
00:00
-0500)
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.
include/stddef.h
patch
|
blob
|
history
diff --git
a/include/stddef.h
b/include/stddef.h
index dbf5a4ae1fe987b9059fe2510171634c4db51bb6..a5bb9ecc2539cdfaec4226dc36d53d59f34cd027 100644
(file)
--- 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