云征万里

导航

新手之自动转存DLL——20150626星期五

 

-------------------菜鸟错例一:---------------------------------------------

int a=0;

if()

{

    int a = GetType();

}

 

这时a = -858993460

很典型的没有初始化的返回值错误。

正确是if里边的a,不能加int。不然相当于又新定义一个小局部变量。

 

----------------------二-----------------------------------------------------

2.1

进程加锁一对好兄弟不要分开他们TvT

构造和函数和析构函数一一对应不偏不倚 TvT

 1 CRabbit::CRabbit(void)
 2 {
 3     C_Init();
 4     m_pMsgContext = NULL;
 5     m_pStreamContext = NULL;
 6     m_pfunOutputStream = NULL;
 7     m_pfunPlatformMsg = NULL;
 8     m_nMaxNum = 0;
 9     InitializeCriticalSection(&m_csListCarrot);
10 }
11 
12 CRabbit::~CRabbit(void)
13 {  
14     C_UnInit();
15     m_pMsgContext = NULL;
16     m_pStreamContext = NULL;
17     m_pfunOutputStream = NULL;
18     m_pfunPlatformMsg = NULL;
19     m_nMaxNum = 0;
20     EnterCriticalSection(&m_csListCamera);
21     while(m_listCarrot.size())
22     {
23         LPC_NodeData p = m_listCarrot.front();
24         delete p;
25         m_listCarrot.pop_front();
26     }
27     LeaveCriticalSection(&m_csListCarrot);
28     DeleteCriticalSection(&m_csListCarrot);
29 }


 

2.2

初始化 ——> 操作 ——> 释放or删除。

关于字符串的输出:

1     char  buff[70];    
2     memset(buff,0,sizeof(buff));    
3     strcpy(buff,pNode->cName);
4     sprintf(buff+strlen(buff),"[%d]--%lu",pNode->nNodeID,pNode->hNode);    

如果节点pNode名字是Rabbit,ID是233,hNode是484,

那么输出效果为:

Rabbit[233]--484

 

----------------------------------------三-----------------

程序进程有问题,导致进程被卡住,再次调试就出错,Cannot open the faile XXXX

退进程,再调试。

posted on 2015-06-26 11:10  云征万里  阅读(166)  评论(0编辑  收藏  举报