News for hackers. Stuff that matters.
Re:Notes on Programming in C (1989) by rootbear on Sunday May 11, 2014 @09:08AM (#7728613)
It seems to me that all this fuss over multiple includes and include guards would be solved by something like a #stop directive:

  #ifdef STDIO_H
  #stop
  #endif
  #define STDIO_H
which would cause the preprocessor to skip the rest of the file. How would this not be a better solution? What am I missing?
Re:Notes on Programming in C (1989) by RegW on Sunday May 11, 2014 @09:36AM (#7728673)
It would be faster, but this would still cause the compiler to open and start parsing the file unnecessarily (possibly multiple times from multiple included files).

Another approach would be to have a pragma that means: "just don't bother including this file again if you see it", and have the compiler remember it. Perhaps there is - its a long time since I programmed in C.

Re:Notes on Programming in C (1989) by tbirdz on Sunday May 11, 2014 @10:23AM (#7728764)
There is #pragma once

It's not standard, but it is supported by many compilers.

Re:Notes on Programming in C (1989) by ahy1 on Sunday May 11, 2014 @12:07PM (#7728996)
I wish for a standard #once directive. It should be very simple to implement, increase preprocessing speed and reduce the size of visually disturbing boilerplate in header files.
Re:Notes on Programming in C (1989) by octopus on Sunday May 11, 2014 @11:48AM (#7728955)
True, supported by GCC, Clang and Visual Studio and probably other compilers ...
Re:Notes on Programming in C (1989) by rootbear on Sunday May 11, 2014 @10:45AM (#7728807)
Good point. Opening a file has non-trivial cost, so perhaps the added cost of burdening the compiler with avoiding needless includes is worth it. As a long time C hacker I hate to say this, but I guess the whole include mechanism is a bad design or, perhaps, a design that didn't scale well.
Re:Notes on Programming in C (1989) by clarry on Sunday May 11, 2014 @09:59AM (#7728717)
If the compiler can remember there's a pragma like that, then it can also remember there's an include guard wrapping the file.