problem with error message: exit status 1 was not declared in this scope

I am a beginner on arduino coding and need help with a problem I’m having with an error. I searched the internet for solutions, but couldn’t find any or didn’t understand them.

I am trying to make a wakeup light and this is the part of the code where I try to set the alarmtime with two buttons. I’m using interrupts, but I keep getting the error message:

exit status 1
‘response’ was not declared in this scope

with this lign highlighted:
attachInterrupt(digitalPinToInterrupt(2),response,RISING);

How can I resolve this issue.
Thanks in advance

int state = 4;
int alarmsetstate = 0;
int previousalarmsetstate;
int Button1 = 2;      
int Button2 = 3;

int h = 7;                //standard alarm time hour
int m = 30;               //standard alarm time minutes
int alarmstartm = 0;          //minutes variable for beginning increase light
int alarmstarth = 7;          //hours variable for beginning increase light
int alarm = 0;


void setup() {
   pinMode(Button1,INPUT);
   pinMode(Button2,INPUT);
   attachInterrupt(digitalPinToInterrupt(2),response,RISING);
   
   Serial.begin(9600);


}

void loop() {
   if(state==4){                         //Set alarm time
    if(alarmsetstate==0){                   // Set hours
      previousalarmsetstate = alarmsetstate;
      while(digitalRead(Button2)==1){                //Set minutes of alarm
        h=h+1;                                            //increase by 1 hour
        if(h==24){                                        //if its 24 hour reset hour to 0
          h=0;
        }
        alarmsetstate=4;
        /*Serial.print(h);
        Serial.print(":");
        Serial.print(m);
        Serial.print(" ");
        if(alarm==1){
          Serial.println("on");
        }
        else{
          Serial.println("off");
        }*/
        delay(400);     
      }
    }
    else if(alarmsetstate==1){
      while(digitalRead(Button2)==1){                //Set minutes of alarm
        m=m+5;                                       //increase alarmtime by 5 min
        if(m==60){                                   // if min equals 60 reset to zero
          m=0;
        }
        Serial.print(h);
        Serial.print(":");
        Serial.print(m);
        Serial.print(" ");
        if(alarm==1){
          Serial.println("on");
        }
        else{
          Serial.println("off");
        }
        delay(400);     
      }
    }
    else if(alarmsetstate==2){
      if(digitalRead(Button2)==1){
        if(alarm==1){
          alarm = 0;
          Serial.print(h);
          Serial.print(":");
          Serial.print(m);
          Serial.print(" ");
          if(alarm==1){
            Serial.println("on");
          }
          else{
            Serial.println("off");
          }
          delay(300);
        }
        else{
          alarm = 1;
          Serial.print(h);
          Serial.print(":");
          Serial.print(m);
          Serial.print(" ");
          if(alarm==1){
            Serial.println("on");
          }
          else{
            Serial.println("off");
          }
          delay(300);
        }
      }
    }
    else if(alarmsetstate==3){
      alarmstartm = m - 30;             //Begin 30 min earlier than setalarm
      alarmstarth = h;
      if(alarmstartm<0){                    //if alarmstart is less than 0 set hour back 
        alarmstartm = 60 + alarmstartm;
        alarmstarth = alarmstarth - 1;
      }
      Serial.println("Alarmtime = ");
      Serial.print(h);
      Serial.print(":");
      Serial.print(m);
      Serial.print(" ");
      if(alarm==1){
        Serial.println("on");
      }
      else{
        Serial.println("off");
      }
      Serial.print(alarmstarth);
      Serial.print(":");
      Serial.println(alarmstartm);
      state = 0;
      alarmsetstate=0;
      Serial.print("ga naar state ");
      Serial.println(state);   
    }
    else if(alarmsetstate==4){                //Display changes
      Serial.print(h);
      Serial.print(":");
      Serial.print(m);
      Serial.print(" ");
      if(alarm==1){
        Serial.println("on");
      }
      else{
        Serial.println("off");
      alarmsetstate=previousalarmsetstate;
    }
   }
  

}

void response(){
  if(state==0){
    state=4;
  }
  else if(state==4){
    if(alarmsetstate==0){
      alarmsetstate=1;
      delay(300);
    }
    else if(alarmsetstate==1){
      alarmsetstate=2;
      delay(300);
    }
    else if(alarmsetstate==2){
      alarmsetstate=3;
      delay(300);
    }
  }
}

void Nightlight(){
  
}

In the IDE press Ctrl-T to format your program. Then check all the braces (curly brackets {}) are balanced. You need a closing } at the end of loop() BEFORE you start defining any more functions...i.e. before void response()

That will get it to compile. Whether it works is then another question.

Steve

Thanks slipstick
This resolved my issue.

Sometimes you have to look at the OTHER error messages in the window below your sketch:

/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino: In function 'void setup()':
sketch_dec10a:18: error: 'response' was not declared in this scope
   attachInterrupt(digitalPinToInterrupt(2), response, RISING);
                                             ^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino: In function 'void loop()':
sketch_dec10a:140: error: a function-definition is not allowed here before '{' token
   void response() {
                   ^
sketch_dec10a:162: error: expected '}' at end of input
   }
   ^
exit status 1
'response' was not declared in this scope

As you discovered, 'response' was not declared at all because of a missing close-bracket. For future reference:
Common compiler errors caused by mismatched brackets:

"does not name a type" or
"expected declaration before" or
"expected unqualified-id before"
Usually means you forgot a '{' or put in an extra '}' in the previous function. Since all of the open brackets have been closed, the compiler is looking for further global declarations (variables or functions). If it finds something that looks like executable code instead of a global declaration it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.

"a function-definition is not allowed here"
(can cause: "'functionName' was not declared in this scope")
Usually means you forgot a '}' or put in an extra '{' in the previous function. Since a set of brackets has not been closed yet the compiler is looking for more code to put in the function. You can't declare a function inside a function so if the compiler finds a function definition it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.

"expected '}' at end of input"
Usually means you forgot a '}' or put in an extra '{' in the last function in the sketch. Since a set of brackets has not been closed yet, the compiler is looking for more code to put in the function. When it hits the end of the file instead it emits an error. Make sure that the brackets in the last function are in matching pairs '{' followed by '}'.

"expected primary-expression before '}' token"
Usually means you have an incomplete statement before a '}'. The block statement (between '{' and matching '}') can only contain complete statements.