I create a simple sketch with 3 tabs:
Sketch #include <Arduino.h>
a_setup
void setup() {
// put your setup code here, to run once:
}
b_loop
void loop() {
// put your main code here, to run repeatedly:
}
Compile fails with nearly 1000 lines of errors, the first two are :
sketch\sketch.ino.cpp:1:1: error: stray '##' in program
##line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\a_setup.ino"
^~
sketch\sketch.ino.cpp:1:3: error: 'line' does not name a type; did you mean 'sinf'?
##line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\a_setup.ino"
^~~~
sinf
a_setup:0:1: error: 'line' does not name a type; did you mean 'sinf'?
In Windows temp folder: Arduino build xx / sketch/ sketch.ino.cpp:
##line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\a_setup.ino"
void setup();
#line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\b_loop.ino"
void loop();
#line 0 "C:\\Users\\Glenn\\Desktop\\sketch\\a_setup.ino"
line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\sketch.ino"
#include <Arduino.h>
#line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\a_setup.ino"
void setup() {
// put your setup code here, to run once:
}
#line 1 "C:\\Users\\Glenn\\Desktop\\sketch\\b_loop.ino"
void loop() {
// put your main code here, to run repeatedly:
}
It seems there is a fault in the compiler, it happens on both my PCs.
Please read the instructions for posting at the top of each forum and edit your post to correctly display the code. The forum editor doesn't keep the sketch formatting without code tags which makes it unreadable. If you post your code in code tags, more forum members will read it.
Post all of the code and the errors, also using code tags.
#include <Arduino.h>
/* a_setup should not be part of your sketch. I've commented it out here.
a_setup
*/
void setup() {
// put your setup code here, to run once:
}
/* b_loop should not be part of your sketch. I've commented it out here.
b_loop
*/
void loop() {
// put your main code here, to run repeatedly:
}
You misunderstand - I have three tabs named Sketch, a_setup and b_loop - named so that the compiler will add them in the correct order.
Sketch (same name as parent folder) contains includes and constructors, a_setup is the setup function, b_loop is the loop function.
It is a strategy that other people have used to break up their code into easily understood pieces. This is just a sample for testing, my real code has around 1300 lines.
Do not do the #include <Arduino.h> in your main sketch (or in any .ino files.)
It's not necessary, and it seems to confuse things. (which is probably a subtle bug of some kind?)
I duplicated your setup, and it works fine with a completely empty sketch file.
Also, the order in which the files are "added" should be unimportant, so the a_ and b_ naming is unnecessary.
It appears that the IDE is inserting the function prototypes in the middle of another pre-processor line. It seems to be related to having a completely unnecessary "#include <Arduino.h>" in the main sketch. Removing Arduino.h in the Sketch avoids the problem. Replacing it with a different #include, like "Servo.h" avoids the problem.