【发布时间】:2014-08-09 04:17:36
【问题描述】:
auto-complete 不适用于具有多个模块的 Emacs C++ 项目。每个子模块所依赖的头文件既存在于模块本身中,也存在于其他模块中。换句话说,一个模块可能包含另一个模块的头文件。
下面是我的示例源代码:
.
├── CMakeLists.txt
├── my_inc
│ ├── CMakeLists.txt
│ ├── myadd.cpp
│ └── myadd.h
├── README.md
└── src
├── CMakeLists.txt
├── Hello.java
├── helper.cpp
├── helper.h
└── main.cpp
main.cpp:
#include "myadd.h"
#include "helper.h"
int main() {
MyAdd add_obj;
Helper h;
h.toString(); // Auto-complete works since Helper is in the same directory.
add_obj. // Auto-complete for add_obj does not work
// because myadd.h is in another directory (my_inc).
}
当我在h之后键入.时弹出方法列表,但对于变量add_obj没有,其类在其他模块my_inc中定义在myadd.h中。
我尝试了一些解决方案(CEDET 相关):
-
(ede-cpp-root-project)此解决方案在这里有效。我不想申请这个,因为
这会让我的
.emacs变大,因为我有很多项目。:include-path这里无法处理 20+ 子模块的复杂头依赖,这使得这个解决方案更像玩具。我更喜欢将配置与.emacs分开。
-
EDE 项目
我通过
ede-new和 c c 创建项目和目标。 t,但这仅用于编译而不是名称,方法自动完成。 -
ede-generic-project如this question 和manual on
ede-generic-project的解决方案中所述,但我收到此错误:eieio-oref:错误类型参数:(或 eieio-object-p class-p),nil
一旦我执行:
M-x
ede-customize-projectRET 在(ede-enable-generic-projects)之后。
环境:我使用 Emacs 24.3 并安装了auto-complete 和cedet2.0。
【问题讨论】:
标签: c++ emacs autocomplete cedet