开发者

xcode4 parameter of incompatible type

开发者 https://www.devze.com 2023-03-21 21:16 出处:网络
A proj开发者_StackOverflow中文版ect that runs fine on Xcode3, fails to compile on Xcode4 with this error:

A proj开发者_StackOverflow中文版ect that runs fine on Xcode3, fails to compile on Xcode4 with this error:

file://localhost/users/Ishaq/Projects/game01/libs/cocos2d/CCLayer.m: error: Semantic Issue: Sending 'ccColor4B' (aka 'struct _ccColor4B') to parameter of incompatible type 'CIColor *'

the code that throws this error is below (from cocos2d-iphone CCLayer.m):

+ (id) layerWithColor:(ccColor4B)color
{
     return [[[self alloc] initWithColor:color] autorelease];
}

Somehow Xcode thinks this code is calling - (id)initWithColor:(CIColor *)color; of CIImage (inside CIImage.h). How can I set Xcode's brain straight? ;-)


I've got the same problem. My resolution was to explicitly cast it proper type which helps the compiler to find the proper class. So the code looks like this:

return [[(CCColorLayer*)[self alloc] initWithColor:color] autorelease];


You could change self to the actual classname CCLayer which should point Xcode in the right direction.


The same thing happened for me when using the "LLVM GCC 4.2" compiler. Changing the compiler setting to "Apple LLVM Compiler 3.0" fixed it.

0

精彩评论

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