fedor.sergeev added a comment.
Hmm... I tried this patch and now the following worries me: - it passes -finclude-if-exists stdc-predef.h on all platforms (say, including my Solaris platform that has no system stdc-predef.h) - it searches all the paths, not just "system include" ones That essentially disallows user to have stdc-predef.h include in my own project, since there is a chance that this user header will be accidentally included by this hidden machinery. >> Yes, I recognize this problem. However, I don't know an acceptable way to >> solve it. Does anyone have a recommendation? I had tried putting angle >> brackets around the file name string to imply a system-only search but that >> didn't work: I guess the >angle brackets are taken to be part of the file >> name. I believe it's intentional that has_include doesn't recognize the >> angle, I see test cases that have __has_include( "<...") Quoting from the >> patch: // For standards compliance, clang will preinclude <stdc-predef.h> // -ffreestanding suppresses this behavior. CmdArgs.push_back("-finclude-if-exists"); CmdArgs.push_back("<stdc-predef.h>"); // This doesn't work to restrict the search to system includes } >I could change the argument scanner for __has_include to recognize the angle >brackets -- would that be acceptable? Alternatively, I could change the flag >to be "finclude-if-exists" into "fsystem-include-if-exists". Then I could >create a new preprocessing keyword(is that the right term?) >__has_system_include and use that instead of __has_include. >I tried this test case with -c -E: >cat test1.c >#if __has_include( "stdio.h" ) >#error it has stdio without angle // This is printed >#else >#error it does not have stdio without angle >#endif >#if __has_include( "<stdio.h>" ) >#error it has stdio with angle >#else >#error it does not have stdio with angle // This is printed >#endif ] cat stdc-predef.h #error I was not expecting to see that ] bin/clang hello-world.c In file included from <built-in>:2: ./stdc-predef.h:1:2: error: I was not expecting to see this! #error I was not expecting to see this! ^ 1 error generated. ] Repository: rL LLVM https://reviews.llvm.org/D34158 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits