cxlib

Why 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.:

https://tronche.com/gui/x/xlib/ICC/client-to-window-manager/XGetClassHint.html

https://tronche.com/gui/x/xlib/window/XDestroyWindow.html

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.


Solution

  • 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;