Setup and Loop

Hi all,

i've been looking through the reference docs both here and at wiring, i'm trying to find some deeper stuff on setup() and loop() (i'm posting here instead of wiring, because this seems to be a more active community, even if wiring is the original).

a couple questions: -> is there any more reference docs on setup and main somewhere (specifically why them)? -> why void setup() instead of int main()? is it just for simplification purposes? (i tried, for fun, to declare an int main() instead of setup() and it through the compiler into a loop.) -> i found a reference to an application in the arduino tinkering pdf that actually shows a program that doesn't include a loop(), but has setup(), is that possible? i defined a function, 'void AnotherFunction() {}' and then tried calling that from setup(), it only compiles if i also define loop().

what i think is going on here is that the compiler is actually adding: int main() { setup(); loop(); return 1; }

is that the case?

Look and see - it's buried in the installation somewhere. The machine in front of me is a bit out of date - running Arduino 0008. It's main.cxx looks like this:

int main(void)

        for (;;)
        return 0;

that's right.. and Wiring / Arduino called user code as "sketch" because real source file, "main.cxx" buried in "/hardware/cores/arduino" then you can't use main() on sketch.

and must complete the setup() and loop() from prototype function to get work.

setup(); was called first on startup but loop(); place in the forever loop that why C code in loop();

that made user can write code on open tail style.