Exit status 1 was not declared in this scope. error message

hi guys so i was trying to compile my sketch and i keep getting this error
exit status 1
‘handleTEMP’ was not declared in this scope.
and i check but i dont see anything wrong why is this happening?
this is my code.

#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
#else
#include <WiFi.h>
#include <WebServer.h>
#endif
#include "DHT.h"
#define DHTPIN 13 //PIN D7
#define DHTTYPE DHT22
#include <WiFiClient.h>
DHT dht(DHTPIN, DHTTYPE);

//Define name of the Wifi & password for creating an access point
const char* ssid = "neneboots";
const char* password = "87654321";
//!!!Your password MUST be a minimum of 8 characters...otherwise neither password nor ssid will be accepted -> default or old ssid&pwd will show up!!! 

//Variables
String stemp,shumi,sinte,a;
float ftemp,fhumi,finte,t,h,f;
//WebPage-----------------------------------------------------------

char webpage[] = R"=(
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
    <meta name="dcterms.created" content="Mon, 06 Jan 2020 05:20:17 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Blue Light</title>
    
    <style type="text/css">
    <!--
    body {
      color:#000000;
      background-color: #0000FF;
      background-image:url('Background Image');
      background-repeat:no-repeat;
    border:3px; 
    border-style:solid; 
    border-color:#000000; 
      padding: 1em;
    font-family:calibri;
    }
    a  { color:#0000FF; }
    a:visited { color:#800080; }
    a:hover { color:#008000; }
    a:active { color:#FF0000; }
    -->
  .content {
  text-align:leftr;
  font-size: large;
  max-width: 500px;
  min-height: 30px;
  margin: auto;
  }
   
    </style>
   </head>
  <body class="content">
  <h2 class="content">Blue Light Incubator</h2>
  <input type="text" id="alrt"><span id="ALERvalue"></span></input>
<form method="post" action="/postForm">
<div class="content">
<label for=temperature> Temperature </label></div>
<div class="content"><input type="number" name="myTemp" id="temperature" placeholder="°C" min="0" max="255" required></input>
</div>
<h4>Temperature reading: <span id="TEMPvalue">0</span>&deg</h4>
<div class="content">
<label for=humidity> Humidity </label></div>
<div class="content"><input type="number" name="myHumi" id="humidity" placeholder="Units" min="0" max="255" required></input>
</div>
<h4>Humidity reading: <span id="HUMIvalue">0</span>%</h4>
<div class="content">
<label for=intensity> Light Intensity</label></div>
<div class="content"><input type="number" name="myInte" id="intensity" placeholder="Lux" min="0" max="1023" required></input>
</div>
<h4>Light Intensity: <span id="LIGHvalue">0</span>lux</h4>

<div class="content">
<input type="submit" value="Apply Settings"></input>
</div>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
  setInterval(function() {getSensorData();}, 500); // Call the update function every set interval e.g. 1000mS or 1-sec
  
       function getSensorData() {
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("TEMPvalue").innerHTML = this.responseText;
          }
        };
        xhttp.open("GET", "TEMPread", true);
        xhttp.send();
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("HUMIvalue").innerHTML = this.responseText;
          }
        };
        xhttp.open("GET", "HUMIread", true);
        xhttp.send();
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("LIGHvalue").innerHTML = this.responseText;}
        };  
        xhttp.open("GET", "LIGHread", true);
        xhttp.send(); 
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            document.getElementById("ALERvalue").innerHTML = this.responseText;
            document.body.style.background = this.responseText == '0' ? 'red' : 'blue'
          }
       
        };
        xhttp.open("GET", "ALERread", true);
        xhttp.send(); 
      }
      
    </script>
  </body>
</html>
)=";

//Setup-----------------------------------------------------------------

void setup() {
  pinMode(5,OUTPUT);
  Serial.begin(115200);

  Serial.print("CONNECTING TO");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(400);
    Serial.print("-");
  }
  Serial.println("");
  Serial.println("WIFI CONNECTED!");

  server.begin();
  Serial.println("MINI SERVER STARTS AT : ");
  Serial.println(WiFi.localIP());
  //Server________________________________
  server.begin();
  
  server.on("/TEMPread", handleTEMP); // To update Temperature called by the function getSensorData
  server.on("/HUMIread", handleHUMI); // To update Humidity called by the function getSensorData
  server.on("/LIGHread", handleLIGH); // To update Pressure called by the function getSensorData
  server.on("/ALERread", handleALER);
  server.on("/postForm", handlePostForm);
  //DHT------------------------------
  dht.begin();  
  }

//Loop------------------------------------------------------------------------------------

void loop() {
  Serial.println(finte);
  analogWrite(5,finte);
  t = dht.readTemperature();
  h = dht.readHumidity();
  f = 0.00;
  a = random(0,1);
  server.handleClient();
  
  // Read temperature as Celsius (the default)
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  delay(500);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

  //Arduino Mega Serial ------------------------------------------------------------------
  if(t <= ftemp){ // 1111111111111111111111111111
  Serial.println("1");
  Serial.println("\n");
  }
  else{
  Serial.println("2"); //222222222222222222222222
  Serial.println("\n");
  }
  if(h <= fhumi){ //33333333333333333333333
  Serial.println("3");
  Serial.println("\n");
  }
  else{
  Serial.println("4"); //4444444444444444444444
  Serial.println("\n");
  }
  
}

//
void serialTx() {
  
}
//Handles--------------------------------------------------------

void handlePostForm()
{
 shumi=server.arg("myHumi");
 stemp=server.arg("myTemp");
 sinte=server.arg("myInte");
 fhumi= shumi.toFloat();
 ftemp= stemp.toFloat();
 finte= sinte.toFloat();
 Serial.println("Settings Applied.");
 Serial.println(ftemp);
 Serial.println(fhumi);
 Serial.println(finte);
 server.send(200, "text/html", webpage);
}
//----------------------------------------------------------------------------------

void handleTEMP() { // This function is called by the script to update the sensor value, in this example random data!
  // temp = String(bme.readTemperature(),2);
  // server.send(200, "text/plain", temp));
  server.send(200, "text/plain", String(t)); //Send sensor reading when there's a client ajax request
}

void handleHUMI() { // This function is called by the script to update the sensor value, in this example random data!
  server.send(200, "text/plain", String(h)); //Send sensor reading when there's a client ajax request
}

void handleLIGH() { // This function is called by the script to update the sensor value, in this example random data!
  server.send(200, "text/plain", String(f)); //Send sensor reading when there's a client ajax request
}

void handleALER() { // This function is called by the script to update the sensor value, in this example random data!
  server.send(200, "text/plain", String(a)); //Send sensor reading when there's a client ajax request
}

you need to declare handleTEMP() before setup():

void handleTEMP();

void setup()
{
   ...
}

Do the same for other functions too;

Assuming you're not getting other errors you didn't tell us about (that error could also occur if there's something very broken above it - I don't see anything, but I could be missing something, I didn't look too hard)

arduino_new:
you need to declare handleTEMP() before setup():

void handleTEMP();

void setup()
{
  ...
}




Do the same for other functions too;

You shouldn't have to do this! The IDE is supposed to generate the function prototypes for you. It doesn't seem to be doing that here though, so his workaround will work. Are you by any chance using an old version of the IDE? There were some bugs with this a few versions back (1.8.9 is probably the best version currently, except on mac os catalina, where you must have 1.8.10)

DrAzzy:
You shouldn’t have to do this! The IDE is supposed to generate the function prototypes for you.

I think it’s pretty well-established that you must provide your own prototype if you use a pointer to the function before it’s defined. That’s happening in this case.

im using 1.8.10 and it seems that by moving all the functions before the setup part fixed this. thanks for the help!

DrAzzy:
It doesn’t seem to be doing that here though, so his workaround will work.

I wouldn’t say: “it’s a workaround”. I would say: “it’s the proper way”.

Here’s a minimal demonstration of the bug:

char foo[] = R"=(
"
)=";
void setup() {
  bar();
}
void loop() {}
void bar(){}
RawStringLiteralBug:5:7: error: 'bar' was not declared in this scope

   bar();

       ^

The preprocessed sketch:

#include <Arduino.h>
#line 1 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
char foo[] = R"=(
"
)=";
void setup() {
  bar();
}
void loop() {}
void bar(){}

Note none of the prototypes were generated. This is the same problem that happened in brownoutee’s original sketch.

I also found a different flavor of bug related to raw string literals:

char foo[] = R"=(
a
)=";
void setup() {
  bar();
}
void loop() {}
void bar(){}

preprocessed sketch:

#include <Arduino.h>
#line 1 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
char foo[] = R"=(
a
)=";
void setup() {
  bar();
#line 6 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
void setup();
#line 9 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
void loop();
#line 10 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
void bar();
#line 6 "E:\\arduino\\RawStringLiteralBug\\RawStringLiteralBug.ino"
}
void loop() {}
void bar(){}

Note that this time the prototypes were generated, but they were inserted inside of setup(). The really strange thing about this one is it only occurs when compiling for ESP8266. If I compile for any other board (including 3rd party boards like ESP32 and ATtinyCore), the protypes are inserted in the correct location.