Pages: [1]   Go Down
Author Topic: Sketches can not be called main Change of IDE 22  (Read 6060 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:


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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
I'm kinda new, but I can get around.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I second this. Had this problem.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49291
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It the way I was taught in college.

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49291
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26280
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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".
Logged

"Pete, it's a fool 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.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
Logged

Colorado
Offline Offline
Full Member
***
Karma: 2
Posts: 220
Arduino 0022 and Ubuntu 11.10 64bit.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !@#$
« Last Edit: January 16, 2011, 08:10:51 pm by mrtaylor » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.  smiley-wink

Lefty
Logged

Colorado
Offline Offline
Full Member
***
Karma: 2
Posts: 220
Arduino 0022 and Ubuntu 11.10 64bit.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 17, 2011, 02:12:43 am by mrtaylor » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: