Added struct field address macros.

Sat, 26 Feb 2005 10:37:20 +0100

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 26 Feb 2005 10:37:20 +0100
changeset 89
17a16ed84bbf
parent 88
308dfa54da3e
child 90
f5a392131875

Added struct field address macros.

pointer.h file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pointer.h	Sat Feb 26 10:37:20 2005 +0100
@@ -0,0 +1,16 @@
+/*
+ * libtu/pointer.h
+ *
+ * Copyright (c) Tuomo Valkonen 2005. 
+ *
+ * You may distribute and modify this library under the terms of either
+ * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
+ */
+
+#ifndef LIBTU_POINTER_H
+#define LIBTU_POINTER_H
+
+#define FIELD_OFFSET(T, F) ((long)((char*)&((T*)0)->F))
+#define FIELD_TO_STRUCT(T, F, A) ((T*)(((char*)A)-FIELD_OFFSET(T, F)))
+
+#endif /* LIBTU_POINTER_H */

mercurial