Mercurial > dovecot > original-hg > dovecot-1.2
changeset 1052:2f6225f9c170 HEAD
Removed STRUCT_OFFSET, offsetof() is ANSI-C for the same purpose. Added
MEMBER() macro to define C99-style struct labels.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 30 Jan 2003 19:51:32 +0200 |
parents | 5c76c96f745f |
children | 28f606ada24a |
files | src/lib/macros.h |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/macros.h Thu Jan 30 19:50:05 2003 +0200 +++ b/src/lib/macros.h Thu Jan 30 19:51:32 2003 +0200 @@ -57,12 +57,10 @@ /* 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; @@ -106,6 +104,13 @@ # 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__