4 ms·
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 fil
by RegW 12y ago
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.
- clarry 12y agoIf the compiler can remember there's a pragma like that, then it can also remember there's an include guard wrapping the file.
- tbirdz 12y agoThere is #pragma once It's not standard, but it is supported by many compilers.
- rootbear 12y agoGood 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.