我正在使用vim编写软件。在这里,我正在使用ctags进行functin定义和声明。我的问题是,当我键入:ctrl+]
时,它跳至obj_rec.h文件中的函数声明部分,但没有从d main.cpp文件中移至obj_rec.cpp部分。我还使用cmd,ctags -R --exclude=.git .
和ctags -R
和ctags -R -f
创建了标记文件
但它也不起作用。这是文件的外观:
test.h
#ifndef TEST_H
#define TEST_H
class test
{
public:
test();
};
testFunc();
#endif // TEST_H
test.cpp
#include "test.h"
#include <iostream>
test::test()
{
std::cout<<"test called"<<std::endl;
}
testFunc() { std::cout<<"test func"<<std::endl;
main.cpp
#include <iostream>
#include "test.h"
int main()
{
test obj;
test();
return 0;
}
在这里,当我将光标放在main.cpp文件中的测试类或测试函数中时,它会跳转到test.h文件,而不是test.cpp。我应该怎么做才能跳到使用ctags实现了test.cpp的地方?
这是我的CMakeLists.txt: cmake_minimum_required(版本2.8)
project(ai_vision)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS} /usr/include/CL/)
set(src main.cpp obj_rec.cpp mean_shift.cpp use_opencl.cpp)
add_executable(${PROJECT_NAME} ${src})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} /usr/lib/x86_64-linux-gnu/libOpenCL.so)
我正在使用ubuntu 18.04,vim版本8.0。
答案 0 :(得分:0)
要转到实现函数的函数定义,您必须使用ctags的标记功能。而不是去函数定义。为此,您必须使用cmd:
标记funcName
(如this文档中所述)。 在这种情况下,您只需键入:标记testFunc,它将进入test.cpp文件测试functin。