编译器对此提示:
int randomSort(id obj1, id obj2, void *context) { // first line
return (arc4random()%3 - 1);
}
第一行:
_cmd undeclared
和
'self' undeclared (first use in this function)
当我在这里不使用 arc4random() 时,即只返回 1,一切都很好。我在这个文件中还有其他 c 函数,它们使用 arc4random() 没有问题。
有什么想法吗?
最佳答案
在使用arc4random()函数前需要告知其签名,即
int arc4random(); // or whatever it looks like
或者包含/导入适当的头文件。如果您的 randomSort 函数确实是第一行,那么显然之前没有一行,因此您不可能包含/导入它(这里不考虑预编译头文件)。
关于c - 这个功能有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3174447/