Including ESP8266WiFi.h forces use of function declarations?
Posted: Thu Jan 14, 2016 12:23 am
I'd like to preface this by saying I'm new to C++ and ESP8266 programming, so please don't laugh too hard if it's a stupid question
I noticed that when I include the ESP8266WiFi.h in a sketch, it forces the use of function declarations, otherwise I get a "not declared in this scope" error.
Here's a minimum code example:
This compiles just fine
This on the other hand, gives a compilation error complaining that testFunction was not declared in the scope
(error: 'testFunction' was not declared in this scope)
Therefore, if I include the ESP8266WiFi.h I need to add the function declaration "void testFunction();" somewhere before the setup() function.
So the question is why does including the ESP8266WiFi.h have this effect?
Thanks!
I noticed that when I include the ESP8266WiFi.h in a sketch, it forces the use of function declarations, otherwise I get a "not declared in this scope" error.
Here's a minimum code example:
This compiles just fine
Code: Select all
#include <Ethernet.h>
void setup() {
Serial.begin(9600);
testFunction();
}
void loop() {
}
void testFunction()
{
Serial.println("test");
}
This on the other hand, gives a compilation error complaining that testFunction was not declared in the scope
(error: 'testFunction' was not declared in this scope)
Code: Select all
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
testFunction();
}
void loop() {
}
void testFunction()
{
Serial.println("test");
}
Therefore, if I include the ESP8266WiFi.h I need to add the function declaration "void testFunction();" somewhere before the setup() function.
So the question is why does including the ESP8266WiFi.h have this effect?
Thanks!