https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97537
Bug ID: 97537 Summary: gcc -H Option Issue, incomplete dependency tree listing Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: adrien.guichard at citel dot fr Target Milestone: --- Created attachment 49426 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49426&action=edit source code sample showing the issue. Copied from Stack Overflow: "GCC -H option issue (header dependency tree listing)" https://stackoverflow.com/questions/58864013/gcc-h-option-issue-header-dependency-tree-listing If the content of an included header file evaluates to empty string during repeated inclusion (because of the content being enclosed in an #ifndef statement), then the included header file name is not listed as a dependency of any subsequent header files. Example: $ cat main.cpp #include "header1.h" int main(void) { return 0; } $ cat header1.h #ifndef header1_h #define header1_h #include "header2.h" #include "header3.h" #endif $ cat header2.h #ifndef header2_h #define header2_h #include "header3.h" #endif $ cat header3.h #ifndef header3_h #define header3_h void header3_function1(void); #endif $ gcc -H main.cpp . header1.h .. header2.h ... header3.h Problem: We would expect header3.h to be a dependency of header1.h. Expected output: . header1.h .. header2.h ... header3.h .. header3.h Using the attached file: $ tar xvfz h-option-test-case.tar.gz $ cd h-option-test-case/ $ gcc -H main.cpp Thanks for your support, Adrien