Pages: [1]   Go Down
Author Topic: error message  (Read 352 times)
0 Members and 1 Guest are viewing this topic.
Fort Worth
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-zipper ok once more!
I have a new project consisting of one file (for the moment) and its called 'slave'
it is in the following folder path:
C:\Users\harrison\Documents\Arduino\RSS\slave

my init() function just sets things up..
and its call by loop()

void loop()                                                                    
{
  long packinfo = 0;
  int radioid;
  init();                                                                      /* call init to set things up */
  for(radioid = 0;
blah, blah, blah

but I get this stupid error:
core.a(main.cpp.o): In function `main':
C:\Arduino\arduino-1.0\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'

duh???
what in the world..

HELP Thanks
Cris H
This is Arduino 1.0 on Windows 7(64bit Ultimate)
Logged

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

You need a function called "setup".
You didn't post one.
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.

Offline Offline
Edison Member
*
Karma: 35
Posts: 1419
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and it would be a really good idea to call your init function from setup.
Then the stupid error should go away, no doubt to be replaced by another one :-)

Pete
Logged

Where are the Nick Gammons of yesteryear?

Fort Worth
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you.. works now.. I called my 'setup' function init and I called from my loop().

Its just what im used to.. (C programmers, just get older, and forget more shit than we remember)  smiley-cool

Thanks Again
Cris H.
aka Phoenixcomm.
Logged

Cleveland, TN
Offline Offline
Full Member
***
Karma: 2
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you.. works now.. I called my 'setup' function init and I called from my loop().

That doesn't make sense.

As I understand it, you must have at least the two following functions to make the Arduino program compile correctly:

Code:
void setup()
{

}

void loop()
{

}

Without them it shouldn't work (shouldn't being the key word). What el_supremo was saying is that you should call your init() function from the setup function like so:

Code:
void setup()
{
  init();
}


If it is simple enough, you can just put your initialize activity inside the setup function. If it is complex or you will need to call it later, starting up an LCD for example that might be turned off by the code and needs to be re-initialized at some point, then your init() is a separate function and could be called from setup(). If you call init() from your loop, then you will call it repeatedly unless you use a state variable which adds unneeded complexity except in certain situations like the LCD example where a state would make sense.

Logged

Luck,

Wade

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

Quote
I called my 'setup' function init and I called from my loop().
But Arduino already has an "init" function, called before "setup" :
Code:
#include <Arduino.h>

int main(void)
{
init();

#if defined(USBCON)
USB.attach();
#endif

setup();
   
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
       
return 0;
}
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.

Pages: [1]   Go Up
Jump to: