title: "Makes Pointer from Integer without a Cast" - How do I satisfy GCC?
body: <p>I'm writing my first X11 applications in C and I've run into a major problem while trying to retrieve the size of my applications window.</p>
  
  <p><code>temp.c:30:2 warning: passing argument 3 of 'XGetGeometry' makes pointer from integer without a cast</code></p>
  
  <p>I know this is just a warning, but it still results in a <strong>segfault</strong> which isn't fun.  Here is my code:                                          </p>
  
  <pre><code>static void loop();
  static void initialize();
  static void cleanUp();
  static void run();
  
  /* Variables */
  
  static int screenNumber;
  unsigned long White;
  unsigned long Black;
  long eventMask;
  static Display *currentDisplay;
  static Window currentWindow;
  static unsigned int windowWidth;
  static unsigned int windowHeight;
  static GC graphicsController;
  static XEvent XEvents;
  
  void loop() {
          XGetGeometry(currentDisplay, currentWindow, DefaultRootWindow(currentDisplay), NULL, NULL, &amp;windowWidth, &amp;windowHeight, NULL, NULL);
  
          XDrawLine(currentDisplay, currentWindow, graphicsController, 0, 0, (int)windowWidth, (int)windowHeight);
          XDrawLine(currentDisplay, currentWindow, graphicsController, 0, (int)windowHeight, (int)windowWidth, 0);
  }
  
  void initialize() {
          currentDisplay = XOpenDisplay(NULL);
          screenNumber = DefaultScreen(currentDisplay);
  
          White = WhitePixel(currentDisplay, screenNumber);
          Black = BlackPixel(currentDisplay, screenNumber);
  
          currentWindow = XCreateSimpleWindow(    currentDisplay,
                                                  DefaultRootWindow(currentDisplay),
                                                  0, 0,
                                                  500, 500,
                                                  0, Black,
                                                  White);
  
          XMapWindow(currentDisplay, currentWindow);
          XStoreName(currentDisplay, currentWindow, "rGot - X11");
  
          eventMask = StructureNotifyMask;
          XSelectInput(currentDisplay, currentWindow, eventMask);
  
          do{
                  XNextEvent(currentDisplay, &amp;XEvents);
          }while(XEvents.type != MapNotify);
  
          graphicsController = XCreateGC(currentDisplay, currentWindow, 0, NULL);
  
          XSetForeground(currentDisplay, graphicsController, Black);
  }
  
  void run() {
          eventMask = ButtonPressMask|ButtonReleaseMask;
          XSelectInput(currentDisplay, currentWindow, eventMask);
          do{
                  XNextEvent(currentDisplay, &amp;XEvents);
                  loop();
          }while(1==1);
  }
  
  void cleanUp() {
          XDestroyWindow(currentDisplay, currentWindow);
          XCloseDisplay(currentDisplay);
  }
  
  int main(){
          initialize();
          run();
          cleanUp();
          return 0;
  }
  </code></pre>
  
  <p>I know I'm doing something wrong with my pointers 'n such, but I'm fairly new to this...  Here is my setup:</p>
  
  <ul>
  <li>Ubuntu 12.04 LTS</li>
  <li>Compiling with: <code>gcc tempc -o temp -lX11</code></li>
  </ul>
  
  <p><em><strong>For those finding this later - my initial attempts to utilize <code>XGetGeometry</code> were completely wrong!</em></strong></p>
  
  <p>To correctly use it, I had to do the following:</p>
  
  <p><code>XGetGeometry(currentDisplay, currentWindow, &amp;currentRoot, &amp;windowOffsetX, &amp;windowOffsetY, &amp;windowWidth, &amp;windowHeight, &amp;windowBorderWidth, &amp;windowDepth);</code></p>
  
  <p>This was based off of my findings <a href="http://menehune.opt.wfu.edu/Kokua/Irix_6.5.21_doc_cd/usr/share/Insight/library/SGI_bookshelves/SGI_Developer/books/XLib_PG/sgi_html/ch03.html#EX-1002-3-4" rel="nofollow">here</a>.</p>