[cffi-devel] Calculating size of C struct .?!

Frank Goenninger fgoenninger at prion.de
Wed May 10 16:19:33 UTC 2006


Hi again  ;-)

I do have the following C struct:

typedef unsigned long	tcflag_t;
typedef unsigned char	cc_t;
typedef long		speed_t;	/* XXX should be unsigned long */

struct termios {
	tcflag_t	c_iflag;	/* input flags */
	tcflag_t	c_oflag;	/* output flags */
	tcflag_t	c_cflag;	/* control flags */
	tcflag_t	c_lflag;	/* local flags */
	cc_t		c_cc[NCCS];	/* control chars */
	speed_t		c_ispeed;	/* input speed */
	speed_t		c_ospeed;	/* output speed */
};

with NCCS being #define'd to 20.

I need to allocate space for this struct and therefore want to know  
its size ... As I don't need the struct itself I thought about  
calculating the size but I figure there's the problem of getting all  
the padding to count to the size...

How would I do that ?

Thx!!

Frank




More information about the cffi-devel mailing list