[PATCH] D124719: [docs] PCH usage documentation update

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 4 13:48:10 PDT 2022


tahonermann reopened this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Reopening for further discussion or clarification.

The changes appear to suggest that a PCH file won't be implicitly used when an explicit include for the corresponding header is made via the `-include` option, but that is not correct.

  $ cat t.h
  const int i = 0;
  $ cat t.c
  int g = i;
  $ clang t.h
  $ ls -1
  t.c
  t.h
  t.h.gch
  $ clang -c -I. -include t.h t.c
  $ touch t.h
  $ clang -c -I. -include t.h t.c
  fatal error: file '/iusers/thonerma/tmp/pch/t.h' has been modified since the precompiled header 't.h.gch' was built: mtime changed
  note: please rebuild precompiled header 't.h.gch'
  1 error generated.

If the ability to include a PCH file via `-include` is intentional behavior (as I have always believed it to be), then I think the documentation should demonstrate both the `-include` and `-include-pch` methods of using a PCH file.

Please note that gcc also supports implicit use of a PCH file via its -include option <https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124719/new/

https://reviews.llvm.org/D124719



More information about the cfe-commits mailing list