Home AMX User Forum NetLinx Studio

Weird bug or bad code

I noticed something odd the other day, I have a switch statement where the cases are literal strings.
switch(sName)
{	
  case 'M':
  {
   // some code 
  }
}

It all compiles and works correctly except for the case above. If I make the literal 2 characters like 'MM' no problem. If I leave it with one character 'M' I get the famous:

ERROR: (0): C10580: Internal Error: Major system error occurred during code generation

error.

Anyone seen this as well or is my code bad?
Paul

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    It's a bug that's been around for a while. All the single characters have to be at the end of the switch.

    Try this thread:

    http://www.amxforums.com/showthread.php?7172-Switch...Case-problem&p=49428#post49428
  • ericmedleyericmedley Posts: 4,177
    I have to admit that I just don't use chars in a switch / case. It has always seemed to work in a quirky, unreliable way anyway. So, I just learned to avoid them. I usually just do Select/Active. Old habits die hard...
  • viningvining Posts: 4,368
    I like this explanation by KennyProgram.
    http://www.amxforums.com/showthread.php?1740-post-54

    There are other posts that discuss switch cases using decimal values in ascending order or was it descending? Anyways switch/case have a bunch of quircks. Fortunately you got the compiler error and not code that runs with un-anticipated results.

    If I recall NMarkRoberts also had posts on this subject back in the day. Wonder what ever became of him?
  • a_riot42a_riot42 Posts: 1,624
    Ah yes, I recall this now, but had forgotten about it. I shall put it at the end instead. Thanks!
    Paul
Sign In or Register to comment.