This is the Arduino main function of the AVR core (ATmega…) (see GitHub):
int main(void)
{
init();
initVariant();
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}
If you replace it with your own, several thing will be missing, e.g. the calls to init()
and initVariant()
.
Furthermore, your code is no longer portable to other platforms (e.g. ESP32, STM32) as the main function looks different on each platform.