Is there a case where including the same header twice is actually helpful?

“Parameterized” header files can be used to simulate C++-ish-style templates in C. In such cases the header file will depend on a number of macros (“template parameters”). It will generate different code depending on the actual “value” of these macros.

So, the typical usage of such header would look as a sequence of “template parameter” macro definitions followed by the #include directive, followed by another sequence of “template parameter” macro definitions followed by the same #include, and so on.

https://stackoverflow.com/a/7186396/187690

When using this technique you will see header files without any include guards or header files with include guards that cover only a portion of the file.

Leave a Comment