Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93215
  • 博文数量: 14
  • 博客积分: 490
  • 博客等级: 下士
  • 技术积分: 150
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-20 11:00
文章分类

全部博文(14)

文章存档

2011年(1)

2008年(4)

2007年(9)

我的朋友
最近访客

分类: C/C++

2008-06-04 00:12:51

    How to calculate the size of the member in a structure? At the same time, how to calculate the offset address the member in a structure? We can define following MACRO definition to settle these problems.
 

/* get the size */

#define FSIZE(type, field) ((size_t)(sizeof(((type *)0)->field)))

/* get the offset address */

#define FOFFSET(type, field) ((size_t)&((type *)0)->field)

阅读(809) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~