首页 > 技术文章 > vxworks一个超级奇怪的错误(parse error before `char')

yuliyang 2013-11-25 21:14 原文

void tserver(int id)
{
        
    if(debug){
    useResource(10000,id);}            
    char msgBuf[MAX_MSG_LEN];
    if (msgQReceive(myMsgQId, msgBuf, MAX_MSG_LEN, WAIT_FOREVER) == ERROR)
    return ;
    printf("Message from client:\n%s\n", msgBuf);
}

竟让会报错

ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I. -IC:\Tornado2.2\target\h\ -DCPU
=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -c ..\homework2.c
..\homework2.c: In function `tserver':
..\homework2.c:54: parse error before `char'
..\homework2.c:55: `msgBuf' undeclared (first use in this function)
..\homework2.c:55: (Each undeclared identifier is reported only once
..\homework2.c:55: for each function it appears in.)
make: *** [homework2.o] Error 0x1

 

void tserver(int id)
{
    char msgBuf[MAX_MSG_LEN];
    if(debug){
    useResource(10000,id);}            
       
    if (msgQReceive(myMsgQId, msgBuf, MAX_MSG_LEN, WAIT_FOREVER) == ERROR)
    return ;
    printf("Message from client:\n%s\n", msgBuf);
}

ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I. -IC:\Tornado2.2\target\h\ -DCPU
=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -c ..\homework2.c

Done.

 

哎,为什么呢?

推荐阅读