|
|
请做EFI的大侠&前辈指点一下,红色标记的那个宏怎么解释?; B& s1 H- e( S) D: N' b% {% y* N( W6 J
我调试发现他是取得那个字段的地址。' L5 n) {3 a( _5 e3 N
大侠能详细解释一下吗?
9 X& ^# A8 I6 }) o& ?, ]" k4 t+ a% ^& ?0 p
这段是我Debug的用例。
& J ?& e. h, N; U" t# Y8 x. ~4 ]. K) p
#include "stdio.h"3 ^& }+ S8 q8 p( U% o+ W6 H; @' B% j7 }
#include "stdlib.h"
4 m7 P7 [3 J5 j% G- Q* `#include "string.h"
6 @+ |6 H/ \" d1 D. ?
5 |8 I/ f) `, @- d( X4 A* _1 M#define CHAR8 unsigned char8 H6 ?4 o! w8 A2 h! i
8 u$ R4 q0 R& O! S& I
typedef struct _tagjany
5 m$ I( J' @& H" C{
5 u& K: Z+ i7 d char name[8];9 ^7 i i9 H) @9 r; u! J
int age;
+ @( W9 D \# K8 E, [/ h3 E- O7 }}JANY, *PJANY;
; {7 p) G7 ?+ w* ~. A2 k/ k g- k% \+ i" A
typedef struct _tagowen0 }8 c- W- h, T; x- f; Z3 Z) h" |$ Z
{( _, e' K, e. I4 r) n9 W" G
JANY jy;
2 G6 |$ Z- T( W( C: K4 L. ` char home[5];
$ l( ?% t! Q2 o" O% N0 w q' [}OWEN, *POWEN;
" x: D) c2 k2 t, x& F% Q& G
# ?; B& p7 x, J% @$ f5 u#define PEI_CORE_HANDLE_SIGNATURE "owen.lu"
# [) H' q8 U& Y+ I3 B! i i, C0 o; D$ K: n
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))) {/ W3 W: j- r! \; s( {& V
0 ?9 P& W$ v. Q
#define PEI_CR(Record, TYPE, Field, Signature) \
5 B" i* ]5 {, H# V& M6 n( H _CR(Record, TYPE, Field)
* J# h: w" Y3 L& y3 x |+ Y" y9 N- z! e7 s& a6 L8 B2 l
#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
( p- e* ]( \- | K4 W- H" _; A7 y2 t (PEI_CR(a, JANY, name, PEI_CORE_HANDLE_SIGNATURE)), i6 {0 F' M1 }. L
, r6 u O2 ]1 \4 z5 h6 [$ F* T avoid main()
: x% ~. B5 L! \5 V4 e{
_$ {6 H3 J0 x/ I PJANY jany;
& k! \$ @4 D) {) d POWEN owen;* k! [$ V' G$ J$ Y& |
jany = malloc(sizeof(JANY));" l% d0 ^3 K8 X8 |/ J' s
owen = malloc(sizeof(OWEN));
% v3 [2 k6 P. q7 R5 G jany = PEI_CORE_INSTANCE_FROM_PS_THIS(owen); R0 |9 s, T2 o! O' ?
free(owen);
4 F: o# D( L- P3 ~% d1 K free(jany);/ ^/ k& x" T; x5 `1 F6 w
return; 2 _$ q0 N: C5 r- L( F0 \0 X
} |
|