ヘッダーファイルで宣言され、一致するソースファイルで定義された関数を使用するには、main()の前にヘッダーファイルをインクルードする必要があることを理解していました。では、なぜ次のコンパイルと実行がうまく機能するのでしょうか。
gcc -o hello hellomain.c hello.c
hellomain.c
int main(int argc, char *argv[])
{
helloPrint();
return 0;
}
hello.h
#ifndef hello_h
#define hello_h
void helloPrint();
#endif
こんにちはC
#include <stdio.h>
void helloPrint()
{
printf("Hello, World!");
}
これは明らかに非常に単純化された例ですが、私の質問を示しています。「hellomain.c」に「hello.h」を含める必要がないのはなぜですか?ありがとう!