What has changed in function scoping rules?

OK - I am coming back to Arduino and coding after about 8 years and 10 years since I wrote the code in question, which I am attempting to migrate from an UNO to ESP8266. I am now also using the 2.3.4 IDE. The code is over a number of tabs/ files which are all visible in the IDE. When compiling I am getting the error :
"error: 'functionName' was not declared in this scope"
Where "functionName" is defined in another tab/ file visible in the IDE.
Have the rules for global scope changed since 2014? Do I need to an additional declarations at the head of each file for functions/ variables where I want to import a function into the scope of that file? I have looked on google for support but found little about scope of functions in C++. My paper reference books are copyright 1987 & 1990......

Welcome back.

Include this code, here.

The way you #include your function is key.
System = #include <header.h>
Local = #include "header.h"
Spelingg and PuNcTuAtIoN matter.

Inside the header.h file is your missing functionName.

1 Like

Does your multiple-tab sketch consist of a number of .ino files or .h/.cpp files?

For the former, the Arduino builder combines all .ino files into one big sketch, generates the function prototypes and hands it over to the compiler. And the builder has been overhauled over the years.

As you mention the ESP8266, the configuration of the compiler used by Espressif is a lot stricter than for the old Arduinos; what used to result in a warning for AVR based boards might now be an error for the ESP8266.

Sterretje, Thanks for the prompt feedback

The multiple tabs are all *.ino files. There are associated .h and .cpp but these seem to have been found and included without error (having made some changes).

I am currently working on other errors that seem to have crept in, may be when these are fixed, this will impact the outcome. It is just that I don’t recall having seen this behaviour before, but as you say they have overhauled the builder and I am using a different complier.

Richard

Header file functions can be changed, removed or inserted as they evolve.

Xfpd,

Thanks for your response it also prompted me to look for other omissions. It is clear now given the comments by Sterretje that the ESP8266 compiler is stricter that this was provoking my issues.

As I get my programming and C++ head back on I will make better progress, but I now at least have code that compiles.

So thanks to you both as helpful members of the Arduino community.

Richard