as araq pointed out, you dont declare pointers and pass them, you allocate
objects and pass pointers to them, in this case for every returned value. this
is not a nim related issue, you can see this if you look at any C code that
uses this.
import
x11/xlib,
x11/x
var
myDisplay: PDisplay
myWindow: Window
myWindowReturn: Window
parentReturn: Window
childrenReturn: PWindow
numChildrenReturn: cuint
myDisplay = XOpenDisplay(nil)
if myDisplay == nil:
quit "Unable to open display"
myWindow = XDefaultRootWindow(myDisplay)
echo repr(myDisplay)
echo repr(myWindow)
let myStatus: Status = XQueryTree(myDisplay, myWindow, addr myWindowReturn,
addr parentReturn, addr childrenReturn, addr numChildrenReturn)
if myStatus != 0:
echo "Query successful!"
# Process the windows here
else:
echo "Query failed"
discard XCloseDisplay(myDisplay)
Run