This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Return Statements inside Case Statements

I encountered a wierd runtime error after compiling and running the following statement:

FuncCall(unsigned char casenum)
{
  switch (casenum)
  {
    case 0x00:
        return 0x0100;
    default:
        return 0x1000;
  }
}

This code compiled with no errors or warnings as part of a much larger chunk of code. When run, this code caused the service watchdog timer to reset the module every time it encountered the statement:

U16 GetReturn;
GetReturn = FuncCall(x);


I then replaced the above code with:

FuncCall(unsigned char casenum)
{
  switch (casenum)
  {
    case 0x00:
        return (0x0100);
    default:
        return (0x1000);
  }
}

and it worked perfect the first time. The only changes to the code consisted of perenthesis changes as listed above. Is there some rule that states constants need to be returned in perenthesis while variables can be returned without them, or have I just encountered a compiler issue? Any ideas?

0