何らかの理由で、ヘッダーガードを使用しているのに、ヘッダーファイル内に複数のコンテンツ宣言があります。私のサンプルコードは以下のとおりです。
main.c:
#include "thing.h"
int main(){
printf("%d", increment());
return 0;
}
things.c:
#include "thing.h"
int increment(){
return something++;
}
things.h:
#ifndef THING_H_
#define THING_H_
#include <stdio.h>
int something = 0;
int increment();
#endif
これをコンパイルしようとすると、GCCはsomething変数の定義が複数あると言います。ifndefはこれが起こらないことを確認する必要があるので、なぜそうなるのか混乱しています。