title: "Implicit declaration of function '_CGSDefaultConnection' is invalid in C99"
body: <p>I'm new to cocoa programming but I picked up a project and keep running into an error. The error is :</p>
  
  <blockquote>
    <p>"Implicit declaration of function '_CGSDefaultConnection' is invalid in C99"</p>
  </blockquote>
  
  <p>I google'd it but couldn't find a definite answer as to what was wrong. But from what I can tell, the line <code>cid = (CGSConnectionID)_CGSDefaultConnection();</code> is not being defined in the correct way.</p>
  
  <p>The full code is below:</p>
  
  <pre><code>#define kIconLevel -2147483628
  + (NSArray*)allIconRects
  {
      NSMutableArray *rects = [NSMutableArray array];
  
      int results[1000];
      int count = -1;
  
      CGSConnectionID cid;
      cid = (CGSConnectionID)_CGSDefaultConnection();
      CGSGetWindowList( cid, 0, 1000, results, &amp;count );
  
      int i = 0;
      for (i = 0; i &lt; count; i++) {
          CGWindowLevel level;
          CGSGetWindowLevel( cid, results[i], &amp;level );
          if (level == kIconLevel) {
              NSRect bounds;
              CGSGetWindowBounds(cid, results[i], (CGRect*) &amp;bounds);
              [rects addObject:[NSValue valueWithRect:bounds]];
          }
      }
  
      return rects;
  }
  </code></pre>
  
  <p>Any help will be greatly appreciated :)</p>