我想編寫一個內聯函數,但出現錯誤。我該如何解決它?內聯函數「未定義符號」錯誤
錯誤信息:
Undefined symbols for architecture i386:
"_XYInRect", referenced from:
-[BeginAnimation ccTouchesEnded:withEvent:] in BeginAnimation.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
代碼:
CGPoint location = CGPointMake(60, 350);
if (XYInRect(location, 53, 338, 263, 369)) {
}
inline BOOL XYInRect(CGPoint location, float MixX, float MixY, float MaxX ,float MaxY){
if (location.x >MixX && location.y >MixY && location.x <MaxX && location.y <MaxY) {
return YES;
} else {
return NO;
}
}
不是一個答案,但你不能只用CGRectContainsPoint而不是滾動您自己的? – jrturton 2012-04-20 08:57:01
使用-O2優化開關進行編譯適用於我,如http://StackOverflow.com/questions/18939482/clang-linker-fails-if-least-o2-wasnt-used所示,另一個問題是我無法更長的發現。 – devon 2017-12-29 02:06:14