mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Project-Setup: clarify .ccls
parent
8cd3189413
commit
aef0d576d5
@ -134,9 +134,11 @@ with open(os.path.join(sys.argv[1], 'compile_commands.json')) as f:
|
|||||||
|
|
||||||
## `.ccls` File
|
## `.ccls` File
|
||||||
|
|
||||||
`.ccls` is a line-based text file at the project root. Its main function is
|
`.ccls` is a line-based text file at the project root. Its specifies compiler
|
||||||
to specify compiler flags needed to properly index your code: `-I` `-D` etc.
|
flags needed to properly index your code: `-I` `-D` etc. The first line
|
||||||
Each line consists of one argument to be added to the compiler command line.
|
specifies the compiler driver (usually `clang`), while each subsequent lines
|
||||||
|
specifies one argument to be added to the compiler command line.
|
||||||
|
|
||||||
No whitespace splitting is performed on the argument, thus `-I foo` cannot be
|
No whitespace splitting is performed on the argument, thus `-I foo` cannot be
|
||||||
used (use `-Ifoo` or `-I\nfoo` for example).
|
used (use `-Ifoo` or `-I\nfoo` for example).
|
||||||
|
|
||||||
@ -151,9 +153,10 @@ Available directives include:
|
|||||||
### `%compile_commands.json`
|
### `%compile_commands.json`
|
||||||
|
|
||||||
By default `.ccls` compiler flags are applied _only_ to files not listed in
|
By default `.ccls` compiler flags are applied _only_ to files not listed in
|
||||||
`compile_commands.json`. If this directive appears first in `.ccls` then after
|
`compile_commands.json`. If this directive appears first in `.ccls`, the
|
||||||
`compile_commands.json` is parsed, the rest of the `.ccls` arguments will be
|
compiler driver must be omitted. After `compile_commands.json` is parsed, the
|
||||||
_appended_ to the compiler flags for files found in `compile_commands.json`.
|
rest of the `.ccls` arguments will be _appended_ to the compiler flags for
|
||||||
|
files found in `compile_commands.json`.
|
||||||
|
|
||||||
### `%c` / `%cpp` / `%objective-c` / `%objective-cpp`
|
### `%c` / `%cpp` / `%objective-c` / `%objective-cpp`
|
||||||
|
|
||||||
@ -182,7 +185,7 @@ You may run into parsing errors like `unknown type name 'class'`.
|
|||||||
|
|
||||||
### Compiler driver
|
### Compiler driver
|
||||||
|
|
||||||
Just use `clang` as the compiler driver (the first line unless `%compile_commands.json` is used).
|
Unless `%compile_commands.json` is used, you _must_ specify a "compiler driver" as the first line of your `.ccls` file.
|
||||||
|
|
||||||
* `clang` defaults to GCCMode (gcc). It correctly treats `.c` files as C and `.cpp` files as C++.
|
* `clang` defaults to GCCMode (gcc). It correctly treats `.c` files as C and `.cpp` files as C++.
|
||||||
* `clang++` defaults to GXXMode (g++). It treats a `.c` file as C++ and issues a warning.
|
* `clang++` defaults to GXXMode (g++). It treats a `.c` file as C++ and issues a warning.
|
||||||
|
Loading…
Reference in New Issue
Block a user