Go Down

Topic: Sketches can not be called main Change of IDE 22 (Read 11591 times) previous topic - next topic


A new change in 22 that was not noted.

You can not name a sketch as main.
This causes strange compiler errors where it will not find the included files.

as such


will not compile



will compile

the errors you get are
Code: [Select]

main.cpp.o: In function `main':
....\arduino/main.cpp:7: undefined reference to `setup'
....\arduino/main.cpp:7: undefined reference to `loop'



I second this.

You can't second something until a motion is made. There was no motion made in the original post, merely an observation.

Now, what "main" tells you about the sketch, and why anyone would want to use that as a name escapes me.

SerialEcho.pde or MorseCodeSender.pde suggest what the sketch is going to do. main.pde does not make any such suggestion.
The art of getting good answers lies in asking good questions.


It the way I was taught in college.

I usually call test programs main, falls back to my first C++ class.


It the way I was taught in college.

Either you misunderstood or the instructor was an idiot. In my humble opinion.

Source code file names should always reflect the purpose of the file. One should not have to hunt through a directory full of files named main_x.c to find the specific file of interest.

I agree that some warning that main.pde would no longer be a valid name could have proven useful, but, I suspect that it never occurred to the team that it was necessary to warn people not to do something dumb. (Again, in my humble opinion.)
The art of getting good answers lies in asking good questions.


I usually call test programs main

Why not call them "test_<something-or-other>"?
Way more descriptive.
Every C program has a "main" - it would be crazy to call all the source files containing "main", "main".
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


I call my sketches "sh#t" until they compile without errors.  ;D



Jan 17, 2011, 02:08 am Last Edit: Jan 17, 2011, 02:10 am by mrtaylor Reason: 1
Just cause they compile don't mean they ain't sh#t.  I figure they must compile and do the job to be one level above sh#t.  Then again I have working on a sketch for three months, compile it dozens of times and it is still !@#$


Just cause they compile don't mean they ain't sh#t.

Your correct of course. But in my case it means I've made one step better then total sh#t.  ;)



Jan 17, 2011, 07:47 am Last Edit: Jan 17, 2011, 08:12 am by mrtaylor Reason: 1
O by the way,  hold down the shift key and then compile the sketch.  Study the output, it will tell you why you can't use main. besides being a really bad file name.  

Don't do this, but if you rename arduino-0022/hardware/arduino/cores/arduino/main.cpp to main_orig.cpp you can save your sketch to main.  This is a dumb idea, it will more then likely break something important.


It seems sketches named 'Tone' do not compile as well. Same errors.
Maybe the common rule is that the sketch name must not repeat any of the reserved words or function names...

Go Up