小编Ant*_*Ant的帖子

使用C中带#define值的数组

我正在使用Jack Ganssles debouce 教程中的一些代码,并尝试使用德州仪器Code Composer Studio v5.5(基于Eclipse)在MSP430上工作.我有一个整数数组的问题,我正在使用一个名为MAXCHECKS的定义值.

#define MAXCHECKS 8;
int Debounced_state;            // Debounced state of the switches
int state[MAXCHECKS];           // Array that maintains bounce status
int Index = 0;                  // Pointer into state
Run Code Online (Sandbox Code Playgroud)

这行int状态[MAXCHECKS]; 抛出2个错误#17期望"]"和#171期望一个声明.如果我将MAXCHECKS更改为8或10的值,则代码构建并加载正常,尽管它不会对开关进行去抖动,但这是我可以处理的事情,因为还没有设置定时器.

define和variables使用的代码如下

int i,j;
state[Index] = (P1IN & 0x0088);
++Index;
j = 0xFF;

for(i=0; i<MAXCHECKS; i++)
{
    j &= state[i];          
}   

Debounced_state = j;            
if (Index>=MAXCHECKS)
{
    Index = 0;
}
Run Code Online (Sandbox Code Playgroud)

我认为它一定是我想念的东西,但此时不确定这个问题呢?

c eclipse code-composer

2
推荐指数
1
解决办法
210
查看次数

标签 统计

c ×1

code-composer ×1

eclipse ×1