| Issue 16: | CC_BRANCH 6661 测试代码即结果 | |
| 1 person starred this issue and may be notified of changes. | Back to list |
/****************************************************************************************\
* 测试环境: cc branch test : CB_CC 6661 , boost 1.44, mingw 4.4.1 ,WIN XP *
\****************************************************************************************/
#include <iostream> // 头文件名对字母大小写敏感 ,应该不敏感更好
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
#include <cmath>
//----------------------------------------------------------use template----------------------------------------------------------------------------------------------------------------------------------------------------------------
class ReturnClass
{
public:
ReturnClass():m_nV(0),m_fV(0.0),m_dV(0.0){;};
int m_nV;
float m_fV;
void print_ret(){std::cout<<"m_nV"<<"m_nV"<<std::endl;};
private:
double m_dV;
};
class Dummy
{
public:
Dummy():m_pub(0),m_priv(0) {};
void Print()
{
std::cout<<"m_pub =" <<m_pub<<std::endl;
std::cout<<"m_priv =" <<m_priv<<std::endl;
};
ReturnClass get_retclass(){;};
ReturnClass* get_retclassptr(){;};
ReturnClass& get_retclassref(){;};
public:
int m_pub;
private:
int m_priv;
};
typedef boost::shared_ptr<Dummy> DummyPtr;
namespace bfs = boost::filesystem ;
namespace bfs2 = boost::filesystem2;
//---------------------------------------------------------------use macro -----------------------------------------------------------------------------------------------------------------------------------------------------------
//macro define
#define add_fuc_imp(fn,re_type,param1_type,param2_type) \
re_type fn##_##re_type(param1_type & param1,param2_type & param2) {return param1 + param2;}
//macro impl
add_fuc_imp(add,float,float,float);
add_fuc_imp(add,float,int,float);
add_fuc_imp(add,float,int,int);
add_fuc_imp(add,double,double,double);
add_fuc_imp(add,int,int,int);
//macro undef
#undef add_fuc_imp // Find declaration of: add_fuc_imp"
//提示没有 : "#define add_fuc_imp ... "
//将改行注释掉后 ,存在上述提示,但提示太多,显然只有一个才合理
int main(void)
{
/****************************************************************************************\
* template test *
\****************************************************************************************/
//-----------------------------------------------------boost 1.44---------------------------------------------------------------------------------------------------------------------------------------------------------------------
boost::filesystem::path a; // 不提示;
boost::filesystem2::path b;//提示正确;
bfs::path c; //不提示;
bfs2::path d;//提示正确;
a.string();//不提示;
b.string();//提示正确;
c.string();//不提示;
d.string();//提示正确;
/*
* 原因:
好像cc不能正确处理下面的代码结构:
* namespace boost {
* namespace filesysyem{
* using boost::filesystem2::path;
* .......
* }
* }
*/
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DummyPtr ptrDummy = DummyPtr(new Dummy());
Dummy* ptr_new = new Dummy();
ptrDummy->Print();//提示错误;
ptrDummy->m_pub; //提示错误
ptrDummy.get()->m_pub ; // 提示错误.
/*
* 原因:cc对模板实例化类型没有很好的处理
*/
ptr_new->m_pub ; //正确提示.
ptr_new->get_retclass().print_ret();// 正确提示..
ptr_new->get_retclass()->;//提示不正确,该操作应该没有提示才合理,因为对象不是指针
ptr_new->get_retclassptr()-> // 正确提示.
ptr_new->get_retclassptr(). //提示不正确,该操作应该没有提示才合理,因为对象是指针
ptr_new->get_retclassref(). // 正确提示.
ptr_new->get_retclassref()-> //提示不正确,该操作应该没有提示才合理,因为对象不是指针
delete ptr_new;
/****************************************************************************************\
* Macro test *
\****************************************************************************************/
int nV = 3;
float fV = 3.;
double dV = 3.00000;
add_float(fV,fV);//有提示,但是当输入 floating型参数 fV后,依然存在三项提示,应该只有一项才合理
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
std::string my_str;
return 0;
}
Oct 2, 2010
关于 CC_BRANCH 还有很大的改进空间,比如:在cc当前文件时,但输入一个函数名称时,可能当前文件中没有包含所需头文件,也因该提示,因为该函数存在于工程tag表中,在提示的同时,应该提示是否将其对应的头文件加上,这样cc更有作用,因为在很多时候,只记住了函数名,而忘记了其头文件是那一个,就像现在的headfix插件一样,可是现在的headfix插件几乎没有任何作用,我想应该将其功能与cc插件结合会更加有用
Oct 2, 2010
废话了那么多,最后还要谢谢版主对CC_BRANCH 的贡献,个人意见:CC_BRANCH是所有CB中非常核心且重要的插件,对编写代码帮助也是最大的,否则此Cb和其他类似IDE比,没有任何优势,且显得笨重,因为其无用插件实在是太多,并超占内存,文档也很不完善 |
ptr_new->m_pub ; //正确提示. ptr_new->get_retclass().print_ret();// 正确提示.. ptr_new->get_retclass()->;//提示不正确,该操作应该没有提示才合理,因为对象不是指针,更好的提示是:该操作不合法或自动纠错 ptr_new->get_retclassptr()-> // 正确提示. ptr_new->get_retclassptr(). //提示不正确,该操作应该没有提示才合理,因为对象是指针 ,更好的提示是:该操作不合法或自动纠错 ptr_new->get_retclassref(). // 正确提示. ptr_new->get_retclassref()-> //提示不正确,该操作应该没有提示才合理,因为对象不是指针,该操作不合法或自动纠错