コンパイラは、各ソース ファイル (および関連するヘッダー ファイルがある場合) に必要な他のすべてのヘッダーが含まれているかどうかを自動的にチェックする機能を提供していますか? または、必要なヘッダーが明示的に含まれていない場合、少なくとも警告を発行しますか?
たとえば、次のようなことを行ったときにコンパイラに報告してもらいたいと思います。
header1.h
#include <string>
...
header2.h
#include "header1.h"
#include <iostream>
std::string blah; //<-- issue warning here, <string> not included explicitly
...
source2.cpp
#include "header2.h"
...
cout << endl; //<-- issue warning here, <iostream> not included explicitly
私は g++ と Visual Studio を使用しているので、私の質問は主にこれらのコンパイラに当てはまります。ありがとう!