メッセージ「警告: 関数の暗黙的な宣言」 質問する

メッセージ「警告: 関数の暗黙的な宣言」 質問する

私のコンパイラ (GCC) は次の警告を出します:

警告: 関数の暗黙的な宣言

なぜ来るのですか?

ベストアンサー1

コンパイラがまだ宣言 (" prototype ")を認識していない関数を使用しています。

例えば:

int main() {
    fun(2, "21"); /* The compiler has not seen the declaration. */       
    return 0;
}

int fun(int x, char *p) {
    /* ... */
}

次のように、関数を直接またはヘッダー内で main の前に宣言する必要があります。

int fun(int x, char *p);

おすすめ記事