1*f4a2713aSLionel Sambuc================================ 2*f4a2713aSLionel SambucFrequently Asked Questions (FAQ) 3*f4a2713aSLionel Sambuc================================ 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc.. contents:: 6*f4a2713aSLionel Sambuc :local: 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel SambucDriver 9*f4a2713aSLionel Sambuc====== 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel SambucI run ``clang -cc1 ...`` and get weird errors about missing headers 12*f4a2713aSLionel Sambuc------------------------------------------------------------------- 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel SambucGiven this source file: 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc.. code-block:: c 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc #include <stdio.h> 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc int main() { 21*f4a2713aSLionel Sambuc printf("Hello world\n"); 22*f4a2713aSLionel Sambuc } 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel SambucIf you run: 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc.. code-block:: console 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc $ clang -cc1 hello.c 30*f4a2713aSLionel Sambuc hello.c:1:10: fatal error: 'stdio.h' file not found 31*f4a2713aSLionel Sambuc #include <stdio.h> 32*f4a2713aSLionel Sambuc ^ 33*f4a2713aSLionel Sambuc 1 error generated. 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc``clang -cc1`` is the frontend, ``clang`` is the :doc:`driver 36*f4a2713aSLionel Sambuc<DriverInternals>`. The driver invokes the frontend with options appropriate 37*f4a2713aSLionel Sambucfor your system. To see these options, run: 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc.. code-block:: console 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc $ clang -### -c hello.c 42*f4a2713aSLionel Sambuc 43*f4a2713aSLionel SambucSome clang command line options are driver-only options, some are frontend-only 44*f4a2713aSLionel Sambucoptions. Frontend-only options are intended to be used only by clang developers. 45*f4a2713aSLionel SambucUsers should not run ``clang -cc1`` directly, because ``-cc1`` options are not 46*f4a2713aSLionel Sambucguaranteed to be stable. 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel SambucIf you want to use a frontend-only option ("a ``-cc1`` option"), for example 49*f4a2713aSLionel Sambuc``-ast-dump``, then you need to take the ``clang -cc1`` line generated by the 50*f4a2713aSLionel Sambucdriver and add the option you need. Alternatively, you can run 51*f4a2713aSLionel Sambuc``clang -Xclang <option> ...`` to force the driver pass ``<option>`` to 52*f4a2713aSLionel Sambuc``clang -cc1``. 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel SambucI get errors about some headers being missing (``stddef.h``, ``stdarg.h``) 55*f4a2713aSLionel Sambuc-------------------------------------------------------------------------- 56*f4a2713aSLionel Sambuc 57*f4a2713aSLionel SambucSome header files (``stddef.h``, ``stdarg.h``, and others) are shipped with 58*f4a2713aSLionel SambucClang --- these are called builtin includes. Clang searches for them in a 59*f4a2713aSLionel Sambucdirectory relative to the location of the ``clang`` binary. If you moved the 60*f4a2713aSLionel Sambuc``clang`` binary, you need to move the builtin headers, too. 61*f4a2713aSLionel Sambuc 62*f4a2713aSLionel SambucMore information can be found in the :ref:`libtooling_builtin_includes` 63*f4a2713aSLionel Sambucsection. 64*f4a2713aSLionel Sambuc 65