Sketches can not be called main Change of IDE 22

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

main.pde
Main.pde
MAIN.pde

will not compile

but

mainx.pde
Mainx.pde
ect

will compile

the errors you get are

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. Had this problem.

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.

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.)

I usually call test programs main

Why not call them "test_"?
Way more descriptive.
Every C program has a "main" - it would be crazy to call all the source files containing "main", "main".

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

Lefty

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. :wink:

Lefty

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...