0

I'm trying to do something like this

#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
    }
}

and I get compile error when I replace GETCART1 with 0 its works fine. Why is that?

Sangeeth Saravanaraj
  • 16,027
  • 21
  • 69
  • 98
Yosefki
  • 383
  • 7
  • 22
  • possible duplicate of [What's wrong with this 1988 C code?](http://stackoverflow.com/questions/8640818/whats-wrong-with-this-1988-c-code) – Bo Persson Dec 28 '11 at 15:03

1 Answers1

7

Drop the semicolons from the defines.

#define GETCART1 0;
                  ^ Drop this

If you don't, by the time the preprocessor is done, your code will end up looking like this:

switch(option){
case (0;) :
       ^
    break;
}
cnicutar
  • 178,505
  • 25
  • 365
  • 392