News for hackers. Stuff that matters.
Re:Notes on Programming in C (1989) by pjmlp on Sunday May 11, 2014 @06:59AM (#7728366)
I am not talking about include guards, rather macros that affect the outcome of specific file.

It is not a very clean way of coding, but there are many enterprise developers that provide files without include guards and include them multiple times.

An example would be generic data structures in C done with macros.

    #define DATA_TYPE int
    #define DATA_NAME intList_t
    #include <list.h>

    typedef struct { /* ... */ } Node;

    #define DATA_TYPE Node
    #define DATA_NAME nodeList_t
    #include <list.h>
Re:Notes on Programming in C (1989) by stormbrew on Sunday May 11, 2014 @07:16AM (#7728399)
It's pretty unlikely that list.h would have a trivial include guard, so I don't see how the above optimization would break it. An include guard in list.h would prevent you from using it properly with or without the optimization.
Re:Notes on Programming in C (1989) by pjmlp on Sunday May 11, 2014 @11:02AM (#7728834)
Not when you #undef it. That was just a possible example.
Re:Notes on Programming in C (1989) by dllthomas on Sunday May 11, 2014 @12:04PM (#7728988)
If list.h has no include guard, it gets included with or without this optimization. If it has an include guard and you #undef it, then it gets included again with or without this optimization. If you it has an include guard and you do not #undef it, it does not get included again, with or without this optimization.

In no case does this optimization change the code emitted.