求解 protothreads 编译不通过。
用的 vc++ 6.0是报错如下--------------------Configuration: hello_pt - Win32 Debug--------------------
Compiling...
main.c
C:\Documents and Settings\Administrator\桌面\pt-1.4\hello_pt\main.c(17) : error C2051: case expression not constant
C:\Documents and Settings\Administrator\桌面\pt-1.4\hello_pt\main.c(30) : error C2051: case expression not constant
C:\Documents and Settings\Administrator\桌面\pt-1.4\hello_pt\main.c(43) : error C2051: case expression not constant
C:\Documents and Settings\Administrator\桌面\pt-1.4\hello_pt\main.c(68) : warning C4013: 'sleep' undefined; assuming extern returning int
执行 cl.exe 时出错.
hello_pt.exe - 1 error(s), 0 warning(s)
工程如下: 直接用官方下载的例子也不能通过 初步怀疑vc++的 __LINE__ 这个保留符号有问题。求问大师们怎么解决的。
#include <stdio.h>
#include <windows.h>
#include "pt.h"
static struct pt pt_h,pt_m,pt_s;
static int ihour=0,iminute=0,isecond=0;
static int c_s=0,c_m=0;
static int clk=0;
PT_THREAD(hour(struct pt*pt))
{
PT_BEGIN(pt);
PT_WAIT_UNTIL(pt,c_m==1);
c_m=0;
if(ihour==23)
ihour=0;
else
ihour++;
PT_END(pt);
}
PT_THREAD(minute(struct pt*pt))
{
PT_BEGIN(pt);
PT_WAIT_UNTIL(pt,c_s==1);
c_s=0;
if(iminute==59)
iminute=0;
else
iminute++;
PT_END(pt);
}
PT_THREAD(second(struct pt*pt))
{
PT_BEGIN(pt);
PT_WAIT_UNTIL(pt,clk==1);
clk=0;
if(isecond==59)
{
isecond=0;
c_s=1;
}
else
isecond++;
PT_END(pt);
}
int main(void)
{
printf("hello.pt\n");
PT_INIT(&pt_h);
PT_INIT(&pt_m);
PT_INIT(&pt_s);
while(1)
{
PT_SCHEDULE(second(&pt_s));
PT_SCHEDULE(minute(&pt_m));
PT_SCHEDULE(hour(&pt_h));
sleep(1);
clk=1;
printf("Time---%d:%d:%d\n",ihour,iminute,isecond);
}
return 0;
} 没人么?求解啊 是不是 vc++6.0 不支持这个哦我找了很久 就发现CASE语句后面的__LINE__ 不知是不是这个的问题呢? 但是我检测了 __LINE__的宏确实是行号呢。编译器报错说不是常量。怎么解决啊。 还没好啊。。。 richards 发表于 2012-7-22 16:49 static/image/common/back.gif
还没好啊。。。
alt+F7 ---->C++ ----->调试信息选择program database ----->OK
页:
[1]