Using clang code-completion with CodeLite v3.0.0

As of codelite v3.0.X, CodeLite supports code completion based on the clang compiler. Note that this page applies only to the 3.0.0 release; see here for more recent versions.



Under Windows, the installer provides all the required components, so there is nothing that you need download or add.

Linux / Mac

Under *nix, you will need to download a clang suitable for your platform from here.

Important: You must install clang version 2.8 or later for code completion to work properly with CodeLite.

Configuring clang

Configuring the clang binary

Once you have installed clang on your machine, you need to tell CodeLite where your clang++ binary is.
To do this go to:
Settings | Tags Settings | clang | Cache

And enter the path to your clang++ binary as shown in the screenshot below:

Adding include paths

Since clang is a full compiler, we need to set the default search paths for the standard include files (like stdio.h, string etc)

This is done from: Settings | Tags Settings | clang | General
In this tab you can set the paths manually (each path should be on a separate line in the 'search paths' text area) or let CodeLite help you by clicking on the 'Suggest search paths...' button.

Once all the search paths are set, click OK.

Setting priorities between clang / ctags

CodeLite can work with both parsers at the same time.
However, you can (and should) set your preference for which engine to try first.

The following table describes CodeLite's behavior for the combination of the two check boxes 'Enable clang code completion' and 'Use clang completion over ctags completion':

Enable clang code completionUse clang completion over ctags completionDescription
X CodeLite will use the ctags parser first. If that fails, it will try again using the clang parser
XXonly the clang code completion is used
  only the ctags parser is used

By default CodeLite sets both checkboxes to FALSE (i.e. un-checked).

Working with standard CodeLite projects

When working with standard CodeLite projects (i.e. projects which are using CodeLite's generated makefiles) clang completion should work out of the box. If it doesn't, please report it.

Working with custom-build projects

Custom-build projects cause a problem, since CodeLite does not know which compilation flags/include paths/macros should be passed to clang for producing code completion.
CodeLite solves this problem by allowing the user to enter them himself.

These flags can be set in 2 levels:

  • The workspace
  • The project

The workspace level

Right-click on the workspace icon in the workspace view and select Workspace settings | Code Completion
This will pop up the following dialog:

This dialog is divided into three areas:

  • Search paths
  • Compile flags
  • Macros

Search paths: In this text box you can enter the include paths for clang. Each include path should be placed on a separate line.

Compile flags: Enter here the compilation flags (e.g. -g or -Wall) that should be passed to clang. Note that this text box also accepts backticks expressions (e.g. `wx-config --cflags`). Each flags/expression entry should be placed on a separate line.

Macros: Enter here the macros that should be passed to clang (e.g. _WIN32=1). Each macro should be placed on a separate line.

The project level

You can also specify a set of flags/include paths/macros per project. This is done from:
Right-click on your project, Project Settings | Code Completion
The project's code completion page is identical to the workspace one above.

Edit - History - Print - Recent Changes - Search
Page last modified on December 28, 2011, at 10:24 PM