Negative value in switch statement

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was trying to write some code and I was having a problem using a negative value in a switch statement not being executed (in AVR Studio 5.0.1163). I have used a negative value in other C compilers, is this a bug or my stupidity?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Suggest you post the code so it can be reviewed and commented on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Should be OK if the variable is declared as signed

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:
Should be OK if the variable is declared as signed
In the New Testament (Kernighan and Ritchie, 2nd edition) it says that the expression is of type integer,so it's a signed