Go Down

Topic: error message (Read 447 times) previous topic - next topic

phoenixcomm

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

AWOL

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

el_supremo

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

phoenixcomm

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

Thanks Again
Cris H.
aka Phoenixcomm.

Sacman


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: [Select]
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: [Select]
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.

Luck,

Wade

AWOL

Quote
I called my 'setup' function init and I called from my loop().

But Arduino already has an "init" function, called before "setup" :
Code: [Select]
#include <Arduino.h>

int main(void)
{
init();

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

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

Go Up