Stupid Encoder Mistake

Today I was changing my encoder routines over to use Brian Low's Rotary library. A snippet from the routine was:

  switch (result) {
    case DIR_CW:                                  // Turned it clockwise, 16
      tuneChange = 1L;
    case DIR_CCW:                                 // Turned it counter-clockwise\
      tuneChange = -1L;
  newFreq = (long)freqIncrement * tuneChange;

No matter what I did the encoder would not decrease the tuned frequency. As everyone but me sees immediately, the DIR_CCW case comment has the macro-continuation character at the end of the comment, which makes the compiler pretty much ignore the tuneChange in that case. The formatting here makes it obvious. The IDE does not. I don't know how I managed to hit that key while typing the comment, but I did. Just a word to wise.

Nothing at all to do with macros.

removing that trailing slash fixed it. I guess I need to know why it fixed it if it wasn't because the compiler was treating it as a continuation of the comment. Perhaps I shouldn't have called it a macro continuation character.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.