gpt4 book ai didi

objective-c - 内联函数 "undefined symbols"错误

转载 作者:太空狗 更新时间:2023-10-30 03:11:29 29 4
gpt4 key购买 nike

我想写一个内联函数,但是我得到一个错误。我该如何解决?

错误信息:

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;

}
}

最佳答案

铿锵 defaults to C99而不是 GNU sematics ,这意味着原始 inline 不同于 static inlineextern inline

特别是,一个原始的 inline 意味着函数仍然有外部链接,但是内联定义不提供外部链接(你需要 extern inline那个)。

这意味着您需要在不同的翻译单元中添加一个额外的 extern 定义,否则链接将失败。但是,您可能正在寻找 static inline

关于objective-c - 内联函数 "undefined symbols"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10243018/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com