I'm trying to use cons int labels in switch statement but I keep getting errors that the case label does not reduce to an integer constant even thought they are const int variables. I defined the const int variables like this:
const int ADD = 6;
const int AND = 7;
const int OR = 8;
const int XOR = 9;
const int SLT = 10;
const int SLL = 11;
const int SRA = 12;
const int SUB = 13;
and I use them in my switch statement like this:
switch(alu_op_code)
{
case ADD:
C = A + B;
break;
case AND:
C = A & B;
break;
case OR:
C = A | B;
break;
case XOR:
C = A ^ B;
break;
case SLT:
C = A < B;
break;
case SLL:
C = (unsigned int)A << B;
break;
case SRA:
C = A >> B;
break;
default:
C = 0;
break;
}
These are the errors in getting: enter image description here
How do I fix this?