Immediately after the header file comment (and include guards if working on a header file), the minimal list of #includesrequired by the file should be listed. We prefer these #includes to be listed in this order:
Generally it is safer to include ISO headers first (using the ‘#include <...>’ form) so as to minimise the possibility that a later user declaration or macro definition interferes with the correctness of the Standard libraries. It also tends to make pre-compiled header implementations faster and more shareable across a larger set of files.
I would like to suggest revising the LLVM coding standard to place the “System #includes” first.
MartinO
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Generally it is safer to include ISO headers first (using the ‘#include <...>’ form) so as to minimise the possibility that a later user declaration or macro definition interferes with the correctness of the Standard libraries. It also tends to make pre-compiled header implementations faster and more shareable across a larger set of files.
Yes, the PCH implementations I was thinking of are MSVC and GCC. Despite working with CLang/LLVM all the time now, I have not actually used its PCH implementation so I don’t know how it behaves - I really should try it out.
In the past I have had some very nasty bugs that were very difficult to analyse, and it turned out that a user declaration or macro had interfered with the behaviour of the ISO headers that were included after it. In one case a C++ program ended up with a very subtle overloading change that resulted after a “clever” user data type was introduced that unintentionally altered how the overloading resolved in the definitions of some of the template function implementations.
All the best,
MartinO