c++includeinclude-guards

Is it redundant to surround an #include with include guards?


I am used to putting header guards around my objects like:

#ifndef SOMETHING_H
#define SOMETHING_H

class Something {
...
}
#endif

but I have been given code where they also do:

#ifndef SOMETHING_H
#include "something.h"
#endif

for every include. Supposedly, this is better. Why? Is this redundant with guards around the object?


Solution

  • This is discussed in pretty good detail here:
    http://c2.com/cgi/wiki?RedundantIncludeGuards

    Here are the highlights: