hthang1988 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Main() #287

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?
main() function less hidden so I can chose whether I wan't it to just execute 
 for(;;)
   loop();
this is annoying at times

Why?
Give the user greater flexibility in how their program executes

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?
I don't think so...

Original issue reported on code.google.com by gray.mal...@gmail.com on 10 Jul 2010 at 11:31

GoogleCodeExporter commented 9 years ago
You can overwrite the main() function in your Arduino sketch.  I actually do 
this more than I use setup() and loop().  You simply use the following code.

#include <WProgram.h>

int main(void)
{
    init();

    //This is where your program goes.  The default main() just calls setup then
    //continuously call loop().

    return 0;
}

Local main() variable should be declared before init();, and globals are 
declared outside of main().

Original comment by saberbat...@gmail.com on 11 Dec 2010 at 3:20

GoogleCodeExporter commented 9 years ago
I'm not quite sure what you're asking for.  If it's a way to override main(), 
it sounds like that's possible already.  Or was there something else you were 
going for?  If so, please start a new issue for it so it doesn't get lost.

Original comment by dmel...@gmail.com on 15 Aug 2011 at 8:40