Paul <
peps...@gmail.com> wrote in
news:66ad1417-57ce-4e3c...@googlegroups.com:
> I did indeed get both your commands to work in the way that you said.
> However, it's not clear to me from the output exactly which files are
> included in which headers. Maybe, it isn't supposed to be clear, and
> the right way is just to include everything that may be needed, with
> standard header guards used to prevent multiple declarations.
That's right. The only reliable source about which system headers include
other headers is the standard. <iostream> for example is documented to
include <ios>, <streambuf>, <istream> and <ostream>.
> For example, the below code seems to work with gcc. But it might be
> bad, and the better method might be to #include<algorithm> even though
> it isn't needed.
Of course, if your code uses std::max(), it should include <algorithm>.
There is no excuse to avoid that, even if the code might sometimes appear
to accidentally compile without that. And you can be sure all the needed
include guards are present in the system headers.
Cheers
Paavo