问题描述
我最近开始使用 irony-mode
来完成操作在emacs(24.3.1)中.但是,我似乎无法添加其他系统包含路径来打包.
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)
反语模式已正确加载,并且补全对于编译器明确知道的包含路径(即由 echo" | g ++ -v -x c ++ -E-
打印的所有内容)完美地工作,但是其他包含路径 inc
不会被拾取(无论它是相对路径还是绝对路径).
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).
但是,如果我将信息添加到 .clang_complete
文件中并使用 C-c C-b
加载,则会识别并使用包含路径.显然,这不是理想的设置,因为
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
- 我不想为我正在处理的每段代码创建
.clang_complete
文件 -
.clang_complete
文件不会自动加载.
- I don't want to create a
.clang_complete
file for each single piece of code I'm working on - The
.clang_complete
file is not loaded automatically.
是否有一些可行的方法(不涉及每个项目的设置,我不想为每段代码创建项目管理文件)来告知 irony-mode
在哪里寻找头文件?
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?
推荐答案
您可以在此处查看: https://github.com/Sarcasm/irony-mode#i-got-an-error-due-to-stdargh-how解决这个问题
变量 irony-libclang-additional-flags
应该可以满足您的需求.无需调用 irony-reload-flags
.
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.
我建议以下内容:
(setq irony-libclang-additional-flags
(append '("-I" "inc") irony-libclang-additional-flags))
这篇关于具有讽刺意味的模式不包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!