我有模板类 A,定义在 a.hpp
啊
template <...>
A
{
void Test();
};
#include a.hpp
如果让
cscope -bq a.h
然后 cscope 可以找到 Test 声明,但找不到定义。
如果让
cscope -bq a.h a.hpp
然后 cscope 甚至找不到测试声明。有什么建议吗?谢谢你。
哪个平台上的哪个版本的 cscope?
使用如图所示的代码:
#ifndef A_H_INCLUDED
#define A_H_INCLUDED
template <class T> A
{
void Test(T a);
};
#include "a.hpp"
#endif /* A_H_INCLUDED */
#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
然后搜索测试并查看:
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(或降级到它?)。