user2311517 user2311517 - 3 months ago 25
C Question

What does the Xlib specification does not use pointers to struct Window?

Although otherwise working with pointers, all Xlib functions I've seen so far pass their Window struct by value, not by reference. E.g.:

Is there any particular rationale for that? In particular, in the case of XGetClassHint, the first and third parameters are passed by reference but the second isn't.


It looks like Window in those examples isn't a struct; it's just an unsigned long. That is, given:

#include <X11/X.h>
Window w;

If I pass that through gcc -E I see:

$ gcc -E wintest.c | grep Window
typedef XID Window;
Window w;

And XID is:

$ gcc -E wintest.c | grep XID
typedef unsigned long XID;