kx.h macro (TX(T,x),xg,etc) purpose?

Could someone clarify the purpose of the following macros? I’m sureit’s simple, but I couldn’t find it in the C interface documentation.#define TX(T,x) (*(T*)((G*)(x)+8))#define xr x->r#define xt x->t#define xu x->u#define xn x->n#define xx xK[0]#define xy xK[1]#define xg TX(G,x)#define xh TX(H,x)#define xi TX(I,x)#define xj TX(J,x)#define xe TX(E,x)#define xf TX(F,x)#define xs TX(S,x)#define xk TX(K,x)#define xG x->G0#define xH ((H*)xG)#define xI ((I*)xG)#define xJ ((J*)xG)#define xE ((E*)xG)#define xF ((F*)xG)#define xS ((S*)xG)#define xK ((K*)xG)#define xC xGThanks.

they’re just accessors to members of the k struct

typedef struct k0{I r;H t,u;union{G g;H h;I i;J j;E e;F f;S s;struct k0*k;

see

https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC

section - the K Object Structure

That much I understand, but for example:#define TX(T,x) (*(T*)((G*)(x)+8))Is there any point when I might need this?On Apr 4, 11:43?am, Charles Skelton <char…> wrote:> they’re just accessors to members of the k struct>> typedef struct k0{I r;H t,u;union{G g;H h;I i;J j;E e;F f;S s;struct k0k;>> see>> https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC&gt;&gt; section - the K Object Structure>> On Mon, Apr 4, 2011 at 5:28 PM, William Belton <i.am.bel…>wrote:>> > Could someone clarify the purpose of the following macros? I’m sure> > it’s simple, but I couldn’t find it in the C interface documentation.>> > #define TX(T,x) ((T*)((G*)(x)+8))> > #define xr x->r> > #define xt x->t> > #define xu x->u> > #define xn x->n> > #define xx xK[0]> > #define xy xK[1]> > #define xg TX(G,x)> > #define xh TX(H,x)> > #define xi TX(I,x)> > #define xj TX(J,x)> > #define xe TX(E,x)> > #define xf TX(F,x)> > #define xs TX(S,x)> > #define xk TX(K,x)> > #define xG x->G0> > #define xH ((H*)xG)> > #define xI ((I*)xG)> > #define xJ ((J*)xG)> > #define xE ((E*)xG)> > #define xF ((F*)xG)> > #define xS ((S*)xG)> > #define xK ((K*)xG)> > #define xC xG>> > Thanks.>> > –> >

Submitted via Google Groups</i.am.bel…></char…>

maybe.

if you choose to use Arthur’s style or want to compile some code from kx.com.

Potentially that definition could be reduced to

#define tX(t,x) ((x)->t)
 
The longer definition may have dated from a time when we didn’t have anonymous unions on all platforms, and the x->T’s didn’t exist.

Makes sense. Thank you for the clarification. I’ve been lookingthrough some of the code the past few days and it’s taking someadjustment.On Apr 4, 12:26?pm, Charles Skelton <char…> wrote:> maybe.> if you choose to use Arthur’s style or want to compile some code from kx.com> .>> Potentially that definition could be reduced to>> #define tX(t,x) ((x)->t)>> The longer definition may have dated from a time when we didn’t> have anonymous unions on all platforms, and the x->T’s didn’t exist.>> On Mon, Apr 4, 2011 at 5:54 PM, William Belton <i.am.bel…>wrote:>> > That much I understand, but for example:>> > #define TX(T,x) ((T)((G*)(x)+8))>> > Is there any point when I might need this?>> > On Apr 4, 11:43 am, Charles Skelton <char…> wrote:> > > they’re just accessors to members of the k struct>> > > typedef struct k0{I r;H t,u;union{G g;H h;I i;J j;E e;F f;S s;struct> > k0k;>> > > see>> > >https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC&gt;&gt; > > section - the K Object Structure>> > > On Mon, Apr 4, 2011 at 5:28 PM, William Belton <i.am.bel…> > >wrote:>> > > > Could someone clarify the purpose of the following macros? I’m sure> > > > it’s simple, but I couldn’t find it in the C interface documentation.>> > > > #define TX(T,x) ((T*)((G*)(x)+8))> > > > #define xr x->r> > > > #define xt x->t> > > > #define xu x->u> > > > #define xn x->n> > > > #define xx xK[0]> > > > #define xy xK[1]> > > > #define xg TX(G,x)> > > > #define xh TX(H,x)> > > > #define xi TX(I,x)> > > > #define xj TX(J,x)> > > > #define xe TX(E,x)> > > > #define xf TX(F,x)> > > > #define xs TX(S,x)> > > > #define xk TX(K,x)> > > > #define xG x->G0> > > > #define xH ((H*)xG)> > > > #define xI ((I*)xG)> > > > #define xJ ((J*)xG)> > > > #define xE ((E*)xG)> > > > #define xF ((F*)xG)> > > > #define xS ((S*)xG)> > > > #define xK ((K*)xG)> > > > #define xC xG>> > > > Thanks.>> > > > –> > > > You received this message because you are subscribed to the Google> > Groups> > > > “Kdb+ Personal Developers” group.> > > > To post to this group, send email to personal-kdbplus@googlegroups.com> > .> > > > To unsubscribe from this group, send email to> > > > personal-kdbplus+unsubscribe@googlegroups.com.> > > > For more options, visit this group at> > > >http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt; > –> >

Submitted via Google Groups</i.am.bel…></char…></i.am.bel…></char…>