Two ints declared simultaneously, one "does not name a type" I have several integers, all of which are declared and set to zero in setup. However, in a method, I can only modify the value of half of those integers. The method is to read several buttons and return which of them have been pressed (precondition is that no more than one buttons are pressed):

  int readButtons(){
  rbuttonState = digitalRead(right);
  lbuttonState = digitalRead(left);
  sbuttonState = digitalRead(sel);
  obuttonState = digitalRead(off);
  nbuttonState = digitalRead(snooze);
  int ret = -1;
  if (rbuttonState != lastrButtonState){
        if (rbuttonState == HIGH) {
            ret = right;
          }
        }
        if (lbuttonState != lastlButtonState){
          if (lbuttonState == HIGH) {
            ret = left;
          }
        }
        if (sbuttonState != lastsButtonState){
          if (sbuttonState == HIGH) {
            ret = sel;
          }
        }
        if (obuttonState != lastoButtonState){
          if (obuttonState == HIGH) {
            ret = off;
          }
        }
        if (nbuttonState != lastnButtonState){
          if (nbuttonState == HIGH) {
            ret = snooze;
          }
        }
  }
  lastrButtonState = rbuttonState;
  lastlButtonState = lbuttonState;
  lastsButtonState = sbuttonState;
  lastoButtonState = obuttonState;
  lastnButtonState = nbuttonState;
  return ret;
}


Yet I have the errors that

Arduino: 1.6.12 (Mac OS X), Board: "Arduino Nano, ATmega328"

Nixie_Clock_0:65: error: 'lastrButtonState' does not name a type
   lastrButtonState = rbuttonState;
   ^
Nixie_Clock_0:66: error: 'lastlButtonState' does not name a type
   lastlButtonState = lbuttonState;
   ^
Nixie_Clock_0:67: error: 'lastsButtonState' does not name a type
   lastsButtonState = sbuttonState;
   ^
Nixie_Clock_0:68: error: 'lastoButtonState' does not name a type
   lastoButtonState = obuttonState;
   ^
Nixie_Clock_0:69: error: 'lastnButtonState' does not name a type
   lastnButtonState = nbuttonState;
   ^
Nixie_Clock_0:70: error: expected unqualified-id before 'return'
   return ret;
   ^
Nixie_Clock_0:71: error: expected declaration before '}' token
 }
 ^
exit status 1
'lastrButtonState' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -&gt; Preferences.


(The last line of code is line 72).
I am at a complete loss. Any help?
the following code


is properly indented
is missing the declarations of the variables for the 'button states' and the 'prior button states'
has additional text about a format error
is properly indented
has the code blocks properly separated by a single blank line


and now the code

int readButtons()
{
    rbuttonState = digitalRead(right);
    lbuttonState = digitalRead(left);
    sbuttonState = digitalRead(sel);
    obuttonState = digitalRead(off);
    nbuttonState = digitalRead(snooze);
    int ret = -1;

    if (rbuttonState != lastrButtonState)
    {
        if (rbuttonState == HIGH)
        {
            ret = right;
        }
    }

    if (lbuttonState != lastlButtonState)
    {
        if (lbuttonState == HIGH)
        {
            ret = left;
        }
    }

    if (sbuttonState != lastsButtonState)
    {
        if (sbuttonState == HIGH)
        {
            ret = sel;
        }
    }

    if (obuttonState != lastoButtonState)
    {
        if (obuttonState == HIGH)
        {
        ret = off;
        }
    }

    if (nbuttonState != lastnButtonState)
    {
        if (nbuttonState == HIGH)
        {
        ret = snooze;
        }
    }
}  &lt;&lt; extranious closing brace ends the actual function


    lastrButtonState = rbuttonState;
    lastlButtonState = lbuttonState;
    lastsButtonState = sbuttonState;
    lastoButtonState = obuttonState;
    lastnButtonState = nbuttonState;
    return ret;
}