Esp8266 2.4.1 update

Hi,
I installed esp8266 v 2.4.1 by using board manager. During time of compiling there showing the error that the functions are " not declared in this scope ". But there is no problem while I moved that function to top of "void setup()". I just started this please help.

Show code, show error messages.

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 was

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.

. . . . .. .

If I changed the arrangement of the code like below it will run smoothly. . .

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

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

void loop() {
Led();
}

If you want to write your code the 1st way, you need void Led(); at the top of the sketch.

.

ieee488:
If you want to write your code the 1st way, you need void Led(); at the top of the sketch.

.

Isn't one of the USPs of Arduino that you don't need to write prototypes for forward references?

I always do just from practice

TolpuddleSartre:
Isn't one of the USPs of Arduino that you don't need to write prototypes for forward references?

Good point.

I took OP at his word, but I don't get any error when compiling the first version of his sketch.

I always prototype out of habit.

Also, he is using 1.6.9 of the IDE. Not sure if that makes a difference.
I am using 1.8.3 on Linux

1.6.9 has problems with prototype generation, especially with ESP8266.

Update.

Don't they all use the same front-end? :o

TolpuddleSartre:
Don't they all use the same front-end? :o

Improvements are made and bugs fixed/introduced with every release. If every release was identical there would be no point in making them.

In Arduino IDE 1.6.6 and newer, function prototype generation is done by a tool named arduino-builder. An IDE release will often contain a new version of arduino-builder. Arduino IDE 1.6.9 uses arduino-builder 1.3.18. Arduino IDE 1.8.5 uses arduino-builder 1.3.25.

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