XtOffset(3)

✨ XtOffset(3) β€” the XT FUNCTIONS girlies ✨

okay so bestie, we're deep in X Toolkit Intrinsics territory today πŸ’… this whole page lives in the XT FUNCTIONS section of the X manuals, and it's about three lil macros that do very specific math for you so you don't have to. let's get into it 🫢


🌸 NAME 🌸

XtOffset, XtOffsetOf, XtNumber β€” these three cuties help you figure out the byte offset or the number of array elements. that's the whole job. they're little macro besties and they ate πŸ’–


πŸŽ€ SYNTAX πŸŽ€

first things first, you gotta pull in the header:

#include <X11/Intrinsic.h>

then here's the trio, exactly as they show up:

Cardinal XtOffset(Type pointer_type, Field field_name);

Cardinal XtOffsetOf(Type structure_type, Field field_name);

Cardinal XtNumber(ArrayVariable array);

not me obsessing over how clean that is 😭


πŸ¦‹ ARGUMENTS πŸ¦‹

  • array β€” this one specifies a fixed-size array. that's it, that's the vibe ✨
  • field_name β€” the name of the field you want the byte offset of. like, which lil member are we measuring from the start, bestie? πŸ‘€
  • pointer_type β€” a type that's declared as a pointer to the structure. pointer energy only πŸ”₯
  • structure_type β€” a type that's declared as a structure. regular struct vibes, no pointer here πŸ’œ

πŸ’– DESCRIPTION πŸ’–

okay so first up, XtOffset. the way that this macro is usually used is to determine the offset of various resource fields from the beginning of a widget πŸ‘‘ and the slay part? you can use it at compile time in static initializations. no runtime needed, she's built different.

then there's XtOffsetOf, and bestie, this one expands to a constant expression that gives you the offset in bytes to the specified structure member from the beginning of the structure. she's normally used to statically initialize resource lists, and she's more portable than XtOffset, which serves the same function. so like, same job, better travel bag 🧳✨

and finally XtNumber β€” this macro returns the number of elements in the specified argument lists, resources lists, and other counted arrays. she counts. that's her main character moment πŸ’…


🌈 SEE ALSO 🌈

go read these next, fr fr:


not me ending the page like a proper icon β€” this whole thing is from X Version 11, specifically libXt 1.3.1, and it's filed under XtOffset(3). mwah πŸ’‹ periodt πŸŽ€πŸ’œ
πŸ“¦ where this page comes from