gpt4 book ai didi

Objective-C 调用 C 函数 - 链接器命令失败,退出代码为 1

转载 作者:行者123 更新时间:2023-11-30 15:55:34 24 4
gpt4 key购买 nike

我有以下头文件

typedef enum {
MONDAY = 1,
TUESDAY = 2,
WEDNESDAY = 3,
THURSDAY = 4,
FRIDAY = 5,
SATURDAY = 6,
SUNDAY = 7,
} WeekDaysEnum;



NSString* dayToString(WeekDaysEnum theDay)
{
switch (theDay) {
case MONDAY:
return @"Monday";
break;

case TUESDAY:
return @"Tuesday";
break;

case WEDNESDAY:
return @"Wednesday";
break;

case THURSDAY:
return @"Thursday";
break;

case FRIDAY:
return @"Friday";
break;

case SATURDAY:
return @"Saturday";
break;

case SUNDAY:
return @"Sunday";
break;
}
}

对于某些函数 dayToString 会导致以下错误:

linker command failed with exit code 1

如何在 Objective-C .m 文件中调用 dayToString 函数?

最佳答案

将函数从 header 移至单独的源文件或将其声明为内联

关于Objective-C 调用 C 函数 - 链接器命令失败,退出代码为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016410/

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