Enable Javascript


Last Arduino/ESP8266 project (click to open)
Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

ESP8266 sketches earlier versions give this compile error:
        '<function>' was not declared in this scope

Preferred solution:
Declare after the #include statements all functions (except setup() and loop())       

#include <ESP8266WiFi.h> 

/***** prototype declaration *****/
void myFunction(int);
/*** may also in a header file ***
 *********************************/

void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}

void myFunction(int number) {
// your function is first declared as a prototype
}

Alternative solution:
(Re)Arrange the order (place each new function on top)

#include <ESP8266WiFi.h> 

void function_1(int number) {
// this must before function_0
}

void function_0(int number) {  // declare before function_1 = ERROR
// this must after function_1
  function_1(number);
}

// (and so on)

void setup() {
// put your setup code here, to run once:
  function_0(5);
}

void loop() {
// put your main code here, to run repeatedly:
  function_0(5);
}