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