Arduino Forum

Forum 2005-2010 (read only) => Software => Troubleshooting => Topic started by: Agent47 on Dec 22, 2008, 12:29 am

Title: error: redefinition of 'void setup()
Post by: Agent47 on Dec 22, 2008, 12:29 am
Whenever I try to use any of the sample code I find in the playground, I get an error when I try to compile the code.  Here it is:

In function 'void setup()':
error: redefinition of 'void setup()' In function 'void loop()':

What am I doing wrong?

I am currently trying to use the code for a piezo player from this link:
http://arduino.cc/en/Tutorial/Melody
Title: Re: error: redefinition of 'void setup()
Post by: mellis on Dec 22, 2008, 03:28 am
Do you have two tabs in your sketch?  When you drag things into the environment, it adds it to the current sketch when you may want to simply open it.
Title: Re: error: redefinition of 'void setup()
Post by: BetaDelta on Jan 08, 2009, 12:19 am
This can be common. An assumption is that tabs are for new sketches. But they only open another file for some more code; for the same sketch. Meaning you only declare void setup() and void loop() once.

So you may have declared this more than once leading to this error.
Title: Re: error: redefinition of 'void setup()
Post by: patgadget on Jan 08, 2009, 04:33 am
I try compiling it and everything was fine?
Patgadget
Montreal