Comments outside include guards (from a Sutter/Alexandrescu advice)

G

Gennaro Prota

Hi,

after several "tweaks" I think I've finally found a file layout which
I like for my code (in terms of where the copyright line and the
license reference go, where the vim modeline etc.). For included
files, I've stuck so far to the suggestion in C++ Coding Standards
which says:

Don't try to be clever: Don't put any code or comments before
and after the guarded portion, and stick to the standard form
as shown. Today's preprocessors can detect include guards, but
they might have limited intelligence and expect the guard code
to appear exactly at the beginning and end of the header.

but with my final layout having the include guard outside of
everything looks a bit ugly. No big deal, but I'm curious to know if
there are really compilers which get fooled by comments outside the
guard. The documentation for gcc explicitly says

You can put comments outside the wrapper. They will not
interfere with this optimization.

so one point for it :) What about others?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top