【问题标题】:Implicit declaration of function 'pool' is invalid in C99 [duplicate]C99中函数'pool'的隐式声明无效[重复]
【发布时间】:2019-12-19 16:10:12
【问题描述】:

该程序的目标是将大量整数存储在数组中,如下所示。它使用“池”函数来收集索引为 2 的整数,并将“池”返回给主函数。我尝试在 Xcode 11 中编译代码,但在 main 中调用“pool”函数期间出现此错误“函数 'pool' 的隐式声明在 C99 中无效”。我该如何解决?如何将 Xcode 上的编译器更改为 C11 标准?

#include <stdio.h>
#include <stdlib.h>
#define SIZE 1000000000

int group[SIZE];

int main()
{
    pool();
    return 0;
}

int pool()
{
    for (int index = 2; index < SIZE; index++)
    {
        group[index] = 1;
    }
    return 0;
}

【问题讨论】:

  • 在 C11 中它比在 C99 中“更无效”;-)

标签: c xcode c99 c11


【解决方案1】:

你需要在第一次调用函数之前放置函数原型

int pool(void);

int main() 
{
   pool();
   return 0;
}

int pool(void)
{
    for (int index = 2; index < SIZE; index++)
    {
        group[index] = 1;
    }
    return 0;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    • 2013-11-28
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多