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

47 views
Skip to first unread message

William Belton

unread,
Apr 4, 2011, 11:28:38 AM4/4/11
to Kdb+ Personal Developers
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.

Charles Skelton

unread,
Apr 4, 2011, 11:43:13 AM4/4/11
to personal...@googlegroups.com, William Belton
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


section - the K Object Structure


--
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...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.


William Belton

unread,
Apr 4, 2011, 11:54:59 AM4/4/11
to Kdb+ Personal Developers
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...@kx.com> 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 k0*k;
>
> see
>
> https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC
>
> section - the K Object Structure
>

Charles Skelton

unread,
Apr 4, 2011, 12:26:51 PM4/4/11
to personal...@googlegroups.com, William Belton
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.

William Belton

unread,
Apr 4, 2011, 1:58:29 PM4/4/11
to Kdb+ Personal Developers
Makes sense. Thank you for the clarification. I've been looking
through some of the code the past few days and it's taking some
adjustment.

On Apr 4, 12:26 pm, Charles Skelton <char...@kx.com> 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.
>
Reply all
Reply to author
Forward
0 new messages