where is Main()? (Newbie)

Hi, When i wish to create a global variable I initialize it prior to Main(). Where do I put these globals for the ARduino C? Befroe Setup()? Befor Loop()?

thx rik

When the compiler runs, it creates blocks of code for each function. The position of the functions, and any code between functions, is irrelevant (except for forward references).

So, global variables can go before setup(), or between setup() and loop(). The loop function typically goes after the setup() function, but it does not need to.

To answer the question in the title: main() is @ hardware\arduino\cores\arduino\main.cpp> Its contents is

#include <WProgram.h>
int main(void)
{
      init();

      setup();
    
      for (;;)
            loop();     
      return 0;
}

When arduino starts up (is reset) main is called, which first calls setup() and then loop() in an endless for loop.