<name> not declared in this scope - IDE 1.8.1

I have a sketch comprising 6 tabs which compiled under a previous version of the IDE (possibly 1.6.5) but fails under 1.8.1 with a scoping error.

Previously the IDE ordered the tabs in the order in which I created them, with the eponymous one first. Under 1.8.1 it puts them in alphabetical order.

I finally got it to work by renaming all the tabs except the eponymous one with prefixes v, w, x, y and z, and ensuring the tab containing common functions came before tabs which use those functions.

Surely, I shouldn’t have to do that as I didn’t have to before. Is it a bug or a feature?

Regards - Philip

Do you use the .ino extension on all the files? If so, try retaining .ino for the eponymous one and change to .cpp for all the others.

Pete

pleriche:
Previously the IDE ordered the tabs in the order in which I created them, with the eponymous one first. Under 1.8.1 it puts them in alphabetical order.

Alphabetical order has always been the intended behavior. There was a bug in Arduino IDE 1.6.12 that caused the tabs to appear in the order added:
https://github.com/arduino/Arduino/issues/5402
but that order was irrelevant because the IDE still concatenates the .ino files with the eponymous file first followed by the rest in alphabetical order. The tabs would have been rearranged in alphabetical order the next time the sketch was opened. The Arduino IDE simply has no mechanism to store the order of tabs.

Typically the order that you define functions doesn’t matter because the function prototypes are all generated at the start of the program so the problem you’re encountering is almost certainly a failure in the Arduino IDE’s automatic function prototype generation system. The system was completely redone after Arduino IDE 1.6.5, causing many problems of this sort. They have gotten most of these issues fixed by now but there are still certain rare cases where the new system is inferior to the old system. If you post your code (use code tags please) we might be able to figure out what is going wrong.

Although tab order is typically not of relevance for function calls, it is for variable and macro definitions. I always preface my tab names with A10, A20, etc. This allows me to insert new tabs at any location without having to rename a bunch of tabs, kind of like line numbers in the old BASIC days.

el_supremo:
change to .cpp for all the others.

How does that help?

Arghhh. I misread the original message.

Pete