]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Removed STRUCT_OFFSET, offsetof() is ANSI-C for the same purpose. Added
authorTimo Sirainen <tss@iki.fi>
Thu, 30 Jan 2003 17:51:32 +0000 (19:51 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 30 Jan 2003 17:51:32 +0000 (19:51 +0200)
MEMBER() macro to define C99-style struct labels.

--HG--
branch : HEAD

src/lib/macros.h

index b350ca7f04d2945e2a4b4fb56b78b677537d3864..78defb1c7d4fc5845516c966090cdc0a5fde027b 100644 (file)
 /* Provide convenience macros for handling structure
  * fields through their offsets.
  */
-#define STRUCT_OFFSET(struct_p, member) \
-    ((long) ((char *) &((struct_p)->member) - (char *) (struct_p)))
 #define STRUCT_MEMBER_P(struct_p, struct_offset) \
-    ((void *) ((char *) (struct_p) + (long) (struct_offset)))
+       ((void *) ((char *) (struct_p) + (long) (struct_offset)))
 #define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
-    (*(member_type *) G_STRUCT_MEMBER_P((struct_p), (struct_offset)))
+       (*(member_type *) G_STRUCT_MEMBER_P((struct_p), (struct_offset)))
 
 /* Provide simple macro statement wrappers (adapted from Perl):
    STMT_START { statements; } STMT_END;
 #  define __attr_unused__
 #endif
 
+/* C99-style struct member definitions */
+#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || __GNUC__ > 2
+#  define MEMBER(name) .name =
+#else
+#  define MEMBER(name)
+#endif
+
 /* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
    macros, so we can refer to them as strings unconditionally. */
 #ifdef __GNUC__