简体   繁体   English

将结构指针传递给函数时出错“ISO C禁止转发参数去除”?

[英]Error “ISO C forbids forward parameter decleration” when passing a struct pointer to a function?

I have the following code, the struct declaration is before the main, so is the function declaration 我有以下代码,struct声明在main之前,因此是函数声明

struct stuff{
        int sale_per_day[Kdays];
        int max_sale;
        };

void set_max();

and that part is in the end... 那部分到底是......

void set_max(struct stuff *point; int n = 0)
{
return;
}

Now what exactly am I doing wrong? 那我究竟做错了什么? I get the 我明白了

"ISO C forbids forward parameter declaration" “ISO C禁止转发参数声明”

error. 错误。 I am working with GCC C89 as per the course demands. 我正按照课程要求与GCC C89合作。

它看起来好像只需要一个逗号而不是分号:

void set_max(struct stuff *point, int n = 0)

There are a few issues with your code snippet: 您的代码段存在一些问题:

void set_max(struct stuff *point; int n = 0)

1) Your prototype does not match the definition. 1)您的原型与定义不符。 C usually complains about that C通常会抱怨这一点
2) You definition contains a semicolon where it should be a comma 2)你的定义包含一个分号,它应该是一个逗号
3) I don't think int n = 0 is allowed in the parameter list either. 3)我认为参数列表中也不允许int n = 0

Please try the following. 请尝试以下方法。

struct stuff {
    int sale_per_day[Kdays];
    int max_sale;
};

void set_max(struct stuff *point);

and

void set_max(struct stuff *point)
{
    int n = 0;
    return;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM