When file1.c includes inc.h (containing the include guard #ifndef INC_H) for the first time, the #define INC_H is performed. But now, when another file2.c includes the same inc.h, is the macro INC_H already defined, all it’s the same story and previous definition is not propagated here?
When file1.c includes inc.h (containing the include guard #ifndef INC_H ) for the first
Share
Yes and No. It depends.
If
file2.cincludes some header which includesinc.h, then yes,INC_His already defined forfile2.c. This is true for any level of inclusion.Else, no it is not already defined.
Guards prevent header from being included in a file, indirectly or directly, more than once!