Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: XQueryTree call illegal on RootWindow ? Message-ID: <9104130237.AA08936@lightning.McRCIM.McGill.EDU> Date: 13 Apr 91 02:37:29 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 45 > Is it illegal to XQueryTree on the root window ? No. > If so, why ? My QueryTree call on the rootwindow consistently yields > a memory fault : in the function XrmStringToQuark : > { > Display *dpy;Window rootw,parent, root, *children; > register status, screen; int children; You should get an error from your compiler for trying to declare two variables called "children" with different types in the same scope. > dpy = XOpenDisplay(""); > rootw = RootWindow(dpy, DefaultScreen(dpy)); > status = XQueryTree(dpy, rootw, &root, &parent, &children, &nchildren); You should get another error here for using an undeclared variable nchildren, unless you have a global by that name. > } I tried your code here (after adding #includes for and and a main() header) and the compiler said "z.c", line 7: redeclaration of children "z.c", line 11: nchildren undefined Changing "int children" to "int nchildren" instead, it compiles and runs. I even added "XCloseDisplay(dpy);" just before the end to make sure that no errors were being generated but not seen, and it still runs fine. > When I do the same thing with a child of the rootwindow, it works > fine. I conjecture this has something to do with precisely what sort of garbage happens to be lying around on the stack. Without more information (a real code sample, say) I can't say much more. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu