我正在使用由其他人撰寫的 C 代碼。編譯程式時:
警告:函式 'shine' 的隱式宣告 [-Wimplicit-function-declaration
我給出了以下代碼的一部分:
struct attribute
{
int type, symb;
float lower, upper;
} examples[MaxExs][MaxAtts];
下面是在 func1() 中呼叫 Shine() 的代碼。
int func1()
{
int e, r, nstrule;
float lwstdist;
...
shine(examples[e], &nstrule, &lwstdist, e);
...
}
下面是shine()的函式定義。
int shine(ex, nstrule, lwstdist, leftout)
struct attribute ex[];
int *nstrule, leftout;
float *lwstdist;
{
...
}
我只想洗掉那個警告。所以我想在代碼的開頭宣告。我嘗試使用:
int shine(xxx, int*, float*, int);
我不知道我是否做對了,什么會代替 xxx。我是 C 的新手。所以我無法弄清楚。如果我能得到一些材料來完成這個特定的事情,這將是一個很大的幫助。
uj5u.com熱心網友回復:
您需要預先宣告struct attribute.
struct attribute;
int shine(struct attribute[], int*, float*, int);
順便提一句。未命名的函式引數不是標準的 C。盡管許多編譯器都接受,因為它在 C 中是允許的,而且實作起來很簡單。
此功能將在即將發布的 C23 標準中添加到 C。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/331912.html
