User Tools

Site Tools


development:emacs:irony

Irony

Irony is a C/C++ minor mode based on libclang, which aims context-sensitive completion and syntax checking using the clang compiler. To do so the following packages from (M)ELPA are needed:

  • irony,
  • company-irony (context-sensitive completion)
  • company-irony-c-headers (header file name completion)
  • flycheck (generic syntax checker)
  • flycheck-irony (C/C++ syntax checking with clang)

But secondly (to get all that stuff working) the clang compiler must know the exact command line options. For that purpose a so called Compiler Database (CDB) must exist in a (sub-) directory, from irony-cdb-search-directory-list. For details on that issue see:

Sometimes i simply use a static .clang_complete file in project root directory, according to this one:

-std=c99
-Wall
-Wextra
-DDEBUG
-D_DEBUG_
-D_GNU_SOURCE
-D_REENRANT
-I.
-I./include
-I/usr/include
-I/usr/include/clang/3.8/include
-I/usr/include/gsl
-I/usr/include/glib-2.0
-I/usr/include/cairo
-I/usr/include/pango-1.0
-I/usr/include/gtk-3.0
When (fly) checking C++ source files including C++ header files named *.h (or C++ header files w/o an extension) then option -D__cplusplus=201103L (example for C++11) might be needed.

In case a project is using CMake then a file compile_commands.json can be generated on each build. For that purpose one has simply to add the following line to CMakeLists.txt:

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

More information on Irony setup can be found on:

development/emacs/irony.txt · Last modified: 2023/04/27 07:16 by Ralf H.