开发者

"Implicit declaration of function '_CGSDefaultConnection' is invalid in C99"

I'm new to cocoa programming but I picked up a project and keep running into an error. The error is :

"Implicit declaration of function '_CGSDefaultConnection' is invalid in C99"

I google'd it but couldn't find a definite answer as to what was wrong. But from what I can tell, the line cid = (CGSConnectionID)_CGSDefaultConnection(); is not being defined in the correct way.

The full code is below:

#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, &count );

    int i = 0;
    for (i = 0; i < count; i++) {
        CGWindowLevel level;
        CGSGetWindowLevel( cid, results[i], &level );
        if (le开发者_如何学Pythonvel == kIconLevel) {
            NSRect bounds;
            CGSGetWindowBounds(cid, results[i], (CGRect*) &bounds);
            [rects addObject:[NSValue valueWithRect:bounds]];
        }
    }

    return rects;
}

Any help will be greatly appreciated :)


C99 requires functions to be prototyped before being used. As this is a hidden API, you need to tell the compiler to look for it at link time rather than in included header files:

extern CGSConnectionID _CGSDefaultConnection();

http://cocoadev.com/DontExposeMe

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜