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

Discussion in 'C++' started by Gennaro Prota, Jun 6, 2007.

  1. 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?

    --
    Gennaro Prota -- C++ Developer, For Hire
    https://sourceforge.net/projects/breeze/
    (replace 'address' with 'name.surname' to mail)
    Gennaro Prota, Jun 6, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fritz Foetzl
    Replies:
    14
    Views:
    566
    Jonathan Turkanis
    Jan 20, 2004
  2. lovecreatesbeauty

    Three #include guards, which will never break?

    lovecreatesbeauty, Jun 7, 2006, in forum: C Programming
    Replies:
    14
    Views:
    435
  3. Replies:
    18
    Views:
    518
    Michael DOUBEZ
    Jun 21, 2007
  4. Johannes Bauer

    Include guards and inclusion order

    Johannes Bauer, Dec 1, 2007, in forum: C++
    Replies:
    18
    Views:
    628
    James Kanze
    Dec 3, 2007
  5. Rui Maciel
    Replies:
    0
    Views:
    201
    Rui Maciel
    Dec 23, 2012
Loading...

Share This Page