[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 --- Comment #13 from Jakub Jelinek --- The error is clear, the header you want to include doesn't exist, which is the case. Usually people use PCH as an optimization, have the header normally in search path and have there also the precompiled version of that header. If it can be used, it is, otherwise it is parsed normally. You chose to not have the header in search path, so when it is not successufully used as PCH, it isn't found. But to mention that in the diagnostic the compiler would need to for all missing headers search again for PCH headers. That doesn't look like a good idea to me.
[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 --- Comment #12 from Marco Trevisan --- Well, I see... At least the error should be a bit clearer though.
[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 Jakub Jelinek changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #11 from Jakub Jelinek --- And that is documented to behave that way. The PCH header must be the first header that contains any tokens. PCH works by dumping the compiler state after compiling the header, and at #include line if found restores that state from the *.gch file. So, there can't be any state before that, it would be lost. And the macros and important options need to match.
[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 Marco Trevisan changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID |--- --- Comment #10 from Marco Trevisan --- (In reply to Jakub Jelinek from comment #9) > certainly contains lots of tokens, so you can't expect PCH to work > after including that header. It needs to go before that. Could be any include... The point here is that any `-include` in command line breaks pch.
[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 Jakub Jelinek changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #9 from Jakub Jelinek --- certainly contains lots of tokens, so you can't expect PCH to work after including that header. It needs to go before that.
[Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462 --- Comment #8 from Marco Trevisan --- It's also relevant to say that just using main.c: #include "gjs_pch.h" int main(int argc, char**argv) { std::string s = "Hi"; return 0; } fails with: ❯ g++ -I _build main.c -o main -include string /tmp/main.c:1:10: fatal error: gjs_pch.h: No such file or directory 1 | #include "gjs_pch.h" | ^~~ While works when not passing any `-include` to the command line