嵌入式offsetof的使用
typedef struct
{
unsigned int array[2];
unsigned int a;
unsigned char b;
unsigned int c;
unsigned int d;
float f;
}foo;
void main(void)
{
int addr=0;
addr = offsetof(foo,c);
P1 =addr;
addr = offsetof(foo,f);
P1 =addr;
addr = offsetof(foo,a);
P1 =addr;
addr = offsetof(foo,d);
P1 =addr;
addr = offsetof(foo,b);
P1 =addr;
while(1);
}
評(píng)論