User Tools

Site Tools


workaround_for_-1_case

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

workaround_for_-1_case [2013/10/22 10:47]
hutch
workaround_for_-1_case [2013/10/22 12:49] (current)
hutch
Line 1: Line 1:
-Using -1 as one of the case values for a switch statement doesn'​t compile as expected on the EDK because ​it appears that the compiler ​is +Using -1 as one of the case values for a switch statement doesn'​t compile as expected on the EDK because ​the compiler ​appears ​to be using an unsigned type for the declaration of the enum variable. Still, it can be useful to use a special value such as -1 to represent the idea that the state machine ​is being reset. I have a suggested usage strategy below. To summarize, the tick method checks to see if the incoming state value is -1. If it is, it assumes that the state machine is being "​reset"​ and returns the next state value to be the initial state. The tick method will also execute the state action for the initial state as expected because the state-action switch is outside of the if-then-else.
  
  
workaround_for_-1_case.txt ยท Last modified: 2013/10/22 12:49 by hutch