Frage

I've recently started using irony-mode for completion in emacs (24.3.1). However, I seem unable to add additional system include paths to package.

I have this code in my config:

(defun ac-cc-mode-clang-hooks ()
  (yas/minor-mode-on)
  (auto-complete-mode 1)

  ;; avoid enabling irony-mode in modes that inherits c-mode, e.g: php-mode
  (when (member major-mode irony-known-modes)
       (irony-mode 1))

  ;; set compiler flags to include header files
  (setq irony-compile-flags '("-Iinc"))
  (irony-reload-flags))

(add-hook 'c++-mode-hook 'ac-cc-mode-clang-hooks)
(add-hook 'c-mode-hook 'ac-cc-mode-clang-hooks)

irony-mode is loaded correctly and completion works perfectly for include paths which the compiler knows explicitly (i.e. everything printed by echo "" | g++ -v -x c++ -E -) but the additional include path inc is not picked up (does not matter whether its a relative or absolute path).

However, if I add the information to the .clang_complete file and load it using C-c C-b the include path is recognised and used. Obviously this is a less than ideal setup because

  1. I don't want to create a .clang_complete file for each single piece of code I'm working on
  2. The .clang_complete file is not loaded automatically.

Is there some working method (which does not involve a per-project setup, I don't want to create project management files for each piece of code) for telling irony-mode where to look for header files?

War es hilfreich?

Lösung

You can take a look here: https://github.com/Sarcasm/irony-mode#i-got-an-error-due-to-stdargh-how-to-solve-this

The variable irony-libclang-additional-flags should meet your needs. It should work without calling irony-reload-flags.

It's not a buffer-local variable though, so you don't need to put it in the hook.

I would recommend the following:

(setq irony-libclang-additional-flags
      (append '("-I" "inc") irony-libclang-additional-flags))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top