MPW and offsetof macro

Ned Rhodes rhodes at grebyn.com
Fri Apr 19 11:47:20 AEST 1991


	The following program fragment will not compile under my current
configuration of MPW.  I have not tried other versions or the latest one
ETO #3.  The same code will compile under gcc, so I think it is a
problem with MPW on the Mac.  Does anyone have any ideas?  I have passed
this on to DTS.


/*

	Shows that offsetof macro is not being properly processed
	
	MPW 3.2b9 and C 3.2b3Q101

*/

#include <stddef.h>

/* macro for sizeof a structure member */
#define sizeofm(struct_t, member) ((size_t)(sizeof(((struct_t *)0)->member)))

/* record definition */
typedef struct {
	char rd_contact[41];	/* contact name (last name first) */
	char rd_title[41];	/* contact job title */
	char rd_company[41];	/* company name */
	char rd_addr[2*40+1];	/* company address */
	char rd_city[26];	/* city */
	char rd_state[3];	/* state */
	char rd_zip[11];	/* zip code */
	char rd_phone[13];	/* phone number */
	char rd_ext[5];		/* phone extension */
	char rd_fax[13];	/* fax number */
	char rd_notes[4*40+1];	/* notes */
} rolodeck_t;

typedef struct {			/* field definition */
	size_t offset;			/* offset of field in record */
	size_t len;			/* field length */
	int type;			/* field data type */
	int flags;			/* flags */
	char filename[100];
					/* name of file to store keys in */
} cbfield_t;

/* field definition list */
const cbfield_t rdfldv[] = {
	{offsetof(rolodeck_t, rd_contact), 
	 sizeofm(rolodeck_t, rd_contact),
	 1,
	 2,
	 "rdcont.ndx"
	}
};

main()
{
}
-- 
Ned W. Rhodes                   (703) 534-2297 (voice)
Software Systems Group          (703) 237-9654 (fax)
2001 North Kenilworth Street	CompuServe : 71321,424
Arlington, VA  22205            rhodes at grebyn.COM



More information about the Comp.lang.c mailing list