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