Posted by Neil Wyatt on 01/08/2017 15:32:29:
…
I imagine main() exists at level above the sketch, along with various #include and #define statements etc. to suit the arduino you are using
Neil
Edited By Neil Wyatt on 01/08/2017 15:35:15
Correct. The code is in main.cpp . The exciting part looks like this:
It can be seen that main.cpp does some private setting up, calls setup() once, and then calls loop() forever, checking the serial interface each time round. As expected on a microcontroller, main() never returns. The built-in main() just makes life a bit simpler for Arduino programmers by hiding a few details.
It's possible to substitute your own main() if there's a need. But that's advanced stuff, making it likely that you are providing your own hardware as well. In that case, something like avrdude would be more suitable for development than the Arduino tool-set.