Referring to John Lakos:
Some years ago I created a more encompassing macro to do the following:
- if in an H-file, insert 'internal' include guards (the normal variety) in the file;
- if in a C file, on an include directive with "" (supposedly your 'own' source code), insert 'external' include guards around the include statement, created from the same rule set as the first bullet;
- if in a C file, on an include directive with <> (foreign code), go into the file, extract the macro name used for include guard, and if found, insert that macro as 'external' include guards around the include directive in the original file.
Precondition: You need to have defined a project, and correctly provided all include paths. It uses the Slick-C macro 'cursor-error', which can also find include files.
External include guards are identical guards as inside the file to be included, but then around the include statement. This prevents the file from being opened, read and closed if the contents aren't needed anyway.
Some people deem this obsolete in times of C++, precompiled headers, #pragma once and similar compiler fetaures, but in my (embedded) experience compile times can be dramatically reduced in most cases while it doesn't harm in all others. Read Lakos for details.
I advertised once on LazyHacker, but aside from one enthousiastic reaction, no one seemed interested. If different here, let me know. I can post the source. It works for me since VSE 6, slightly modified since VSE 8.
FWIW,
Johan