FAQ.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ================================
  2. Frequently Asked Questions (FAQ)
  3. ================================
  4. .. contents::
  5. :local:
  6. Driver
  7. ======
  8. I run ``clang -cc1 ...`` and get weird errors about missing headers
  9. -------------------------------------------------------------------
  10. Given this source file:
  11. .. code-block:: c
  12. #include <stdio.h>
  13. int main() {
  14. printf("Hello world\n");
  15. }
  16. If you run:
  17. .. code-block:: console
  18. $ clang -cc1 hello.c
  19. hello.c:1:10: fatal error: 'stdio.h' file not found
  20. #include <stdio.h>
  21. ^
  22. 1 error generated.
  23. ``clang -cc1`` is the frontend, ``clang`` is the :doc:`driver
  24. <DriverInternals>`. The driver invokes the frontend with options appropriate
  25. for your system. To see these options, run:
  26. .. code-block:: console
  27. $ clang -### -c hello.c
  28. Some clang command line options are driver-only options, some are frontend-only
  29. options. Frontend-only options are intended to be used only by clang developers.
  30. Users should not run ``clang -cc1`` directly, because ``-cc1`` options are not
  31. guaranteed to be stable.
  32. If you want to use a frontend-only option ("a ``-cc1`` option"), for example
  33. ``-ast-dump``, then you need to take the ``clang -cc1`` line generated by the
  34. driver and add the option you need. Alternatively, you can run
  35. ``clang -Xclang <option> ...`` to force the driver pass ``<option>`` to
  36. ``clang -cc1``.
  37. I get errors about some headers being missing (``stddef.h``, ``stdarg.h``)
  38. --------------------------------------------------------------------------
  39. Some header files (``stddef.h``, ``stdarg.h``, and others) are shipped with
  40. Clang --- these are called builtin includes. Clang searches for them in a
  41. directory relative to the location of the ``clang`` binary. If you moved the
  42. ``clang`` binary, you need to move the builtin headers, too.
  43. More information can be found in the :ref:`libtooling_builtin_includes`
  44. section.