26,27:error: expected constructor, destructor, or type conversion before ‘('toke

小小的森林 2017-03-22 05:23:41
26,27:error: expected constructor, destructor, or type conversion before ‘('toke
pthread_mutex_lock (&mutex);

代码部分:
#include "test.hpp"
#include "stub.hpp"

stMsgQueue* wstBtaMsgQue = NULL;
stMsgQueue* wstHftMsgQue = NULL;


//pPairedDevInfLsN wstPairedDevInfLsN_p;
//PairedDevInfLsN wstPairedDevInfLsN_Next;
//Type_uWord ConHFTDeviceID=0;

static Type_uHWord nuhCnnCount = 0;
static Type_uHWord uwModuleID[IPC_CONNECT_COUNT];
static pthread_mutex_t cnn_lock;


//static Type_uHWord cnn_lock;

pthread_mutex_lock (&mutex); //这两行出错
pthread_mutex_unlock (&mutex); //26,27行


static Type_uHWord mutex;
Type_sHWord put_connect_info(Type_uWord module_id)
{
//AFW_LOG(btapp_log,AFW_LOG_LEVEL_DEBUG,AFW_LOG_STRING("[BTApp IPC]put_connect_info called"));

Type_Bool is_md_exsit = FALSE;
Type_uHWord i = 0;

if(nuhCnnCount >= IPC_CONNECT_COUNT)
return CNN_RET_ERR;
pthread_mutex_lock(&cnn_lock);

for(i = 0; i < nuhCnnCount;i++)
{
if(module_id == uwModuleID[i])
{
is_md_exsit = TRUE;
break;
}
}

if(!is_md_exsit)
{
uwModuleID[nuhCnnCount] = module_id;
nuhCnnCount++;
}else{
pthread_mutex_unlock(&cnn_lock);
return CNN_RET_EXSIT;
}

pthread_mutex_unlock(&cnn_lock);

return CNN_RET_OK;
}
...全文
281 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
小小的森林 2017-03-23
  • 打赏
  • 举报
回复
谢谢提示
自信男孩 2017-03-22
  • 打赏
  • 举报
回复
pthread_mutex_lock (&mutex);  
pthread_mutex_unlock (&mutex);      
这两行需要放到函数里。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧