相关疑难解决方法(0)

我怎么看C/C++源文件在Visual Studio预处理后?

比方说,我有许多预处理指令源文件.是否有可能看到它的外观预处理器是用它做之后?

c c++ debugging visual-studio-2005 c-preprocessor

201
推荐指数
8
解决办法
9万
查看次数

使用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
查看次数

由于#define MAX导致C++出错

我只是用C++开发一个简单的堆栈程序.

#include<iostream>
#define MAX 3;
using namespace std;

class stack
{
private:
    int arr[3];
    int top;

public:
    stack()
    {
        top=-1;
    }
    void push(int item)
    {
        if(top==MAX-1)
        {
            cout<<endl<<"STACK FULL";
            return;
        }
        top++;
        arr[top]=item;
        cout<<endl<<"Pushed "<<item;
    }
    int pop()
    {
        if(top==-1)
        {
            cout<<endl<<"STACK EMPTY";
            return NULL;
        }
        int temp=arr[top];
        top--;
        return temp;
    }
};

int main()
{
    stack s;
    s.push(1);
    s.push(2);
    s.push(3);
    s.push(4);

    cout<<endl<<"Popped "<<s.pop();
    cout<<endl<<"Popped "<<s.pop();
    cout<<endl<<"Popped "<<s.pop();
    cout<<endl<<"Popped "<<s.pop();
}
Run Code Online (Sandbox Code Playgroud)

我把这作为礼物

naveen@linuxmint ~/Desktop/C++ $ g++ stack.cpp -o stack
stack.cpp: …
Run Code Online (Sandbox Code Playgroud)

c++

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

使用Visual Studio 2010在C语言中使用宏来切换语句

我正在尝试做这样的事情

#define GETCART1 0;
#define GETCART2 1;

void helper(int *Array,int length,int counter, int option){
    if (length > counter){
        switch(option){
        case (GETCART1) :

            break;
        }//switch
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到编译错误,当我更换GETCART1使用0其作品的罚款.这是为什么?

c macros visual-studio-2010

0
推荐指数
1
解决办法
320
查看次数

宏定义语法

为什么我们不在宏定义的末尾加分号?

我知道预处理器处理代码的这些部分.这两者之间有关系吗?如果是,那是什么?

与编译器相比,它与预处理器处理事物的方式之间的区别有何关​​系?如果是,这些差异是什么?

c

0
推荐指数
1
解决办法
66
查看次数