代码之家  ›  专栏  ›  技术社区  ›  dontWatchMyProfile

这个函数有什么问题?

  •  0
  • dontWatchMyProfile  · 技术社区  · 14 年前

    编译器对此抱怨:

    int randomSort(id obj1, id obj2, void *context) { // first line
        return (arc4random()%3 - 1);
    }
    

    _未声明的命令

    你知道吗?

    1 回复  |  直到 14 年前
        1
  •  3
  •   Eiko    14 年前

    在使用arc4random()函数之前,您需要告诉它的签名,即。

    int arc4random();  // or whatever it looks like
    

    或包含/导入适当的头文件。如果您的randomSort函数确实是第一行,那么很明显之前没有行,这使得您不可能包含/导入它(这里不考虑预编译头)。