关于cscope index hpp文件的问题

时间:2010-08-18 03:31:39

标签: c++ cscope

我有模板类A,定义在a.hpp

A.H

template <...>
A
{
void Test();
};
#include a.hpp

如果让

cscope -bq a.h

然后cscope可以找到Test声明,但找不到定义。

如果让

cscope -bq a.h a.hpp
然后cscope甚至找不到测试声明。 任何建议? 谢谢。

1 个答案:

答案 0 :(得分:0)

哪个版本的cscope在哪个平台上?

使用如下所示的代码:

A.H

#ifndef A_H_INCLUDED
#define A_H_INCLUDED
template <class T> A
{
    void Test(T a);
};
#include "a.hpp"
#endif /* A_H_INCLUDED */

a.hpp

#ifndef A_HPP_INCLUDED
#define A_HPP_INCLUDED
template <class T> A::Test(T a) { return !!a; }
#endif /* A_HPP_INCLUDED */

使用在MacOS X上编译的cscope 15.7a(在10.6.4上运行,可能在早期版本上编译),我做了:

cscope -b -q a.*
cscope -d

然后搜索Test并查看:

C symbol: Test

  File  Function Line
0 a.h   <global> 5 void Test(T a);
1 a.hpp Test     3 template <class T> A::Test(T a) { return !!a; }

搜索A::Test时会显示错误:

This is not a C symbol: A::Test

那么,从表面上看,你需要升级到cscope 15.7a(或降级到它?)。