這是一個頭文件警告:隱式函數聲明在C99中無效?
#include <stdio.h>
int m = 18;
int x = 4;
int singles (n) {
if (n == 1)
return 0;
return doubles(n-1);
}
int doubles (n) {
if (n == 1)
return 0;
return triples(n-1);
}
int triples (n) {
if (n == 1)
return m;
return (singles(n-1) + doubles (n-1) + triples (n-1))*(m-1);
}
,這是主要的文件
#include <stdio.h>
#include "test.h"
int main() {
printf("%d",singles (x));
}
所以這是非常複雜,我在-least.The的想法是,在主函數中我會打電話單打(x)其中x = 4因此它更像單打(4),它將調用雙打(3),這將調用三元組(2),這將調用所有單打(1),這將返回0,雙打(1)返回0和三元組(1)將返回m。
,所以我得到的錯誤是
./test.h:13:12: warning: implicit declaration of function 'doubles' is invalid
in C99 [-Wimplicit-function-declaration]
return doubles(n-1);
^
./test.h:20:12: warning: implicit declaration of function 'triples' is invalid
in C99 [-Wimplicit-function-declaration]
return triples(n-1);
^
2 warnings generated.
我試圖創建的第一個腳本頭文件的.h,然後做了第二次.c的腳本,我嘗試編譯將無法工作。我試圖導入標題,以儘量避免這個錯誤,但它似乎並沒有工作。 非常感謝
高度懷疑這與C,C++,*和* C#。請只標記真正涉及的語言(在這種情況下,似乎只有C)。 – crashmstr
你爲什麼要標記'c#'這個問題? – Eser
對不起,我對編碼很陌生,以爲他們是同一件事。 – Charana