Smart auto completion for C++ in Emacs

Many people have asked for C++ auto completion in Emacs. Until recently no really good alternative has been available. Parsing C++ is very hard and using tools like ctags works well for C but not so much for C++. CEDET/Semantics works for small C++ projects but is slow and quite complicated to install and configure.

LLVM/Clang is a compiler architecture supported by Apple that seeks to become a serious alternative to GCC. The project started just a few years ago but it already provides a high quality C and Objective C compiler that performs better than GCC in several benchmarks. The C++ support is still not complete but good enough to compile many parts of boost. Clang is not just a compiler, it also has includes great tools for code analysis. Clang is BSD licensed which enables close interaction with third part applications without licensing issues. is a wonderful hack that lets Emacs interface with Clang. The result is great and fast auto completion inside Emacs. I’m sure we will see more uses of Clang in other projects.

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Smart auto completion for C++ in Emacs

  1. Needs this patch:

    diff -du /Users/dave/DropBox/home/.emacs.d/elhome/lib/clang-completion-mode.el /var/folders/w6/w6aHCL\+5EVeBUsDYKAF0pU\+\+\+TI/-Tmp-/buffer-content-97274uaK
    — /Users/dave/DropBox/home/.emacs.d/elhome/lib/clang-completion-mode.el 2010-01-13 01:44:51.000000000 -0500
    +++ /var/folders/w6/w6aHCL+5EVeBUsDYKAF0pU+++TI/-Tmp-/buffer-content-97274uaK 2010-12-07 14:17:02.000000000 -0500
    @@ -53,10 +53,10 @@
    :group ‘clang-completion-mode)

    ;;; Extra compilation flags to pass to clang.
    -(defcustom clang-flags “”
    +(defcustom clang-flags nil
    “Extra flags to pass to the Clang executable.
    This variable will typically contain include paths, e.g., -I~/MyProject.”
    – :type ‘string
    + :type ‘(repeat (string :tag “Argument” “”))
    :group ‘clang-completion-mode)

    ;;; The prefix header to use with Clang code completion.

    Diff finished. Tue Dec 7 14:17:02 2010

  2. kristianr says:

    Dave> Thanks. I just want to tell you that I’m not a maintainer or developer of this emacs mode. You should contact the llvm/clang-developers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s