Thread (9 messages) 9 messages, 1 author, 2020-08-17
STALE2162d

[PATCH 3/8] bcache-tools: list.h: only define offsetof() when it is undefined

From: Coly Li <hidden>
Date: 2020-08-17 12:06:17
Subsystem: the rest · Maintainer: Linus Torvalds

For new gcc headers, offsetof() is defined, the definition in list.h
will be warned as redefined.

This patch checks whether offsetof() is defined, and only defines local
version of offsetof() when it is not defined by gcc headers.

Signed-off-by: Coly Li <redacted>
---
 list.h | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/list.h b/list.h
index 55d2bb4..458281d 100644
--- a/list.h
+++ b/list.h
@@ -25,10 +25,12 @@
  */
 /*@{*/
 
+#ifndef offsetof
 /**
  * Get offset of a member
  */
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif /* offsetof*/
 
 /**
  * Casts a member of a structure out to the containing structure
-- 
2.26.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help