Rule suggesting to add source file corresponding with header file

I guess this could maybe be a rule. The idea comes from John Lakos, in his presentations, like this CppCon 2018: John Lakos “C++ Modules and Large-Scale Development” - YouTube And it’s about the topic in the thumbnail

The rule is that every header file should have a corresponding source file that includes the header file “first”, for the purpose of ensuring that every header file compiles on it’s own. In other words, this ensures that the header file includes all the relevant header files, instead of relying that the necessary headers being included by the users.

The rule seems equally relevant in both C and C++.

For very small header files that depend on nothing, like a header file that only contains something like an enum, this could be a noisy rule. I don’t know if some effort should go into figuring out if the header file makes use of symbols that would require other headers to be included.

Thanks @torgeir.skogen,
I created a ticket to keep track of this rule idea.