Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp8266 2.4.1 update issue #4605

Closed
ghost opened this issue Apr 4, 2018 · 7 comments
Closed

Esp8266 2.4.1 update issue #4605

ghost opened this issue Apr 4, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented Apr 4, 2018

jeesonraphael
Hi,
I have installed esp8266 v 2.4.1 by using board manager. During the time of compiling there showing an error -- functions are " not declared in this scope ". But if I moved that function to the top of "void setup()" code is running smoothly. I am just a beginner in this.

. . . . error code . . . . .

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}


void loop() {
  Led();
}


void Led() {
  digitalWrite(LED_BUILTIN, LOW);   
  delay(1000);                      
  digitalWrite(LED_BUILTIN, HIGH);  
  delay(2000);
}

. . . . error message . . . . .

Arduino: 1.6.9 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

WARNING: Spurious .github folder in 'IRremoteESP8266' library
C:\Users\jeesonraphael\Desktop\Blink\Blink.ino: In function 'void loop()':

Blink:8: error: 'Led' was not declared in this scope

   Led();

       ^

exit status 1
'Led' was not declared in this scope

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

. . . . . running code . . . . .

void Led() {
 digitalWrite(LED_BUILTIN, LOW);
 delay(1000);
 digitalWrite(LED_BUILTIN, HIGH);
 delay(2000);
}


void setup() {
 pinMode(LED_BUILTIN, OUTPUT);
}


void loop() {
 Led();
}
@d-a-v
Copy link
Collaborator

d-a-v commented Apr 4, 2018

You indeed found that functions must be declared before using them, this is how C and C++ languages works.
(some would say that order does not matter inside C++ classes, but we are not there).

The spurious warning is just a warning from the Arduino IDE. It is up to you to (re)move that directory from that library if you think you can do it.

Anyway this is not an issue with the esp8266/arduino core. So closing.

@d-a-v d-a-v closed this as completed Apr 4, 2018
@igrr
Copy link
Member

igrr commented Apr 4, 2018

@d-a-v in Arduino, it should work. Arduino preprocessor should generate prototypes automatically so that users don't have to bother writing forward declarations. I can imagine what you think about this practice, but that's how it is supposed to work. If it doesn't, it means that we have pulled in some header file into Arduino.h which confuses the preprocessor, messing up prototype generation. Need to check this.

@igrr igrr reopened this Apr 4, 2018
@d-a-v
Copy link
Collaborator

d-a-v commented Apr 4, 2018

Thanks @igrr
@jeesonraphael sorry for my Arduino's basics ignorance :-]

@devyte
Copy link
Collaborator

devyte commented Apr 4, 2018

I can't reproduce this with Arduino IDE 1.8.2 and the provided code above, I get a clean build.
Either there is an installation issue, or the issue is in IDE 1.6.9, which is ancient and not the version mentioned in our current docs, or there is a lib conflict or incompatible libs in OP's path.
I don't see a core issue here.
Closing as can't reproduce.

@devyte devyte closed this as completed Apr 4, 2018
@lrmoreno007
Copy link
Contributor

@igrr as you know it is the theory, but there are many cases in which the theory fails. An attempt has already been made to improve this on IDE Arduino 1.6.7 (17 december 2015)(see changelog https://www.arduino.cc/en/Main/ReleaseNotes) and many issues arduino/arduino-builder#68 (in this one you collaborated ;-) ). But it still fails sometimes.

An example of many other, fail with no-UTF path:
7 august 2016 --> arduino/Arduino#5216


That is why it is good practice to declare the functions before using them, it costs nothing.

In any case, it is not a problem with the ESP8266-Arduino framework.

Regards.

@d-a-v
Copy link
Collaborator

d-a-v commented Apr 4, 2018

I have tested the failing sketch with arduino-1.9beta, works too.
Lots of surprises in arduino :)
@lrmoreno007 thanks for all these instructive pointers.

@ghost
Copy link
Author

ghost commented Apr 5, 2018

I updated the arduino version 1.6.9 to 1.8.5. Now it is working perfectly.
Thank you everyone for your support. . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants