【发布时间】:2017-06-30 07:44:09
【问题描述】:
我在执行 for 循环时遇到问题,我创建了一个包含已定义值的静态表,然后我将我的表作为参数传递给函数进行处理。 基本上我的代码如下所示:
#define ID_01 0x0000
#define ID_02 0x0001
#define ID_03 0x0002
#define ID_04 0x0003
#define ID_05 0x0004
#define ID_06 0x0005
#define ID_07 0x0006
#define ID_08 0x0007
#define ID_09 0x0008
/*...
*/
#define ID_LAST 0xFFFF
static char table[]={
ID_01, ID_02 ,ID_03, ID_04, .... , ID_LAST}
void process( char *table){
int LastId=0;
char *Command;
for ( Command=table; LastId==0 ; Command++){
switch(Command)
{
case ID_01:
do_stuff01();
break;
case ID_02:
do_stuff02();
break;
...
case ID_LAST:
LastId=1;
break;
default:
break;
}
}
}
我尝试打印一些消息进行调试,但程序不执行任何打印,即使是在 for 循环之前和之后的那些。
但是当我将 for 循环更改为:
for(i=0;i<10;i++)
所有消息都已打印。但我必须像一开始那样处理。
PS:这部分代码是在运行到微控制器的操作系统任务中执行的,我只是一个初学者。
【问题讨论】:
标签: c operating-system microcontroller