struct class 内存结构初探-内存模型顺序和变量的实际添加顺序一致

时间:2022-06-07 02:55:53

typedef struct structTest {

char xchar;

int xint;

int yint;

}xStruct;

@interface ViewController ()

{

char xchar;

int xint;

int yint;

}

xStruct xTest = {'a', 1, 2};

NSLog(@"%p,%p, %p",&xTest.xchar, &xTest.xint, &xTest.yint);

NSLog(@"%p,%p, %p", &xchar, &xint, &yint);

2017-02-22 14:39:01.957 structTest[53135:4290831] 0x7fff5f694a60,0x7fff5f694a64, 0x7fff5f694a68

2017-02-22 14:39:01.958 structTest[53135:4290831] 0x7fe5825115c0,0x7fe5825115c4, 0x7fe5825115c8