6

irony-mode is: an Emacs minor-mode that aims at improving the editing experience for the C, C++ and Objective-C languages. It works by using a combination of an Emacs package and a C++ program (irony-server) that uses libclang. (provides code completion with either company-mode or auto-complete)

So, For tiny projects that I might be working on, which are compiled with a simple g++ foo.c -o foo, how should I put the compile files to make irony-mode work?

And what about larger projects that uses CMake, SCons and others! How do I get those compilations flags for projects that make use of these piece of software to build themselves?

Sorry, but irony-mode assumes a lot of things and dismiss any in deep explanation about these things it mentions, and since I'm not a full time C++ developer, figuring out myself is quite hard.

  • 2
    If you explain your question a bit better you could instigate the interest of people who don't know irony mode. What compilation flags are you taking about? Why are small projects any different from large ones? – Malabarba Oct 8 '14 at 6:08
  • As I understand it, for your example g++ foo.c -o foo, there is simply no compilation flag. Not sure to understand what this mode is about, but if it is parsing the output buffer (for errors?), it may need to know about flags like -Wall and such? – T. Verron Oct 8 '14 at 7:08
  • is for providing code completion! – shackra Oct 8 '14 at 7:12
6

irony-mode's author here.

So, For tiny projects that I might be working on, which are compiled with a simple g++ foo.c -o foo, how should I put the compile files to make irony-mode work?

If you don't have any flags you don't have to do anything. You give irony-mode some flags only so that it can parse your file. In your case, no flags are needed to parse the buffer.

And what about larger projects that uses CMake, SCons and others! How do I get those compilations flags for projects that make use of these piece of software to build themselves?

Please check out the compilation database documentation.

Right now irony-mode asks you to create a .clang_complete file. This file should contain the compilation flags, one flag per line and it should be placed in the directory of your file or a parent directory.

There is also support for the JSON Compilation Database format. The CMake and Ninja build systems are supported for example.

When a build system, such as SCons, does not support generating a JSON Compilation Database, there are a few tools capable of producing a compile_commands.json by watching the build. For example intercept-build from scan-build or the Bear tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.