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