Void setup vs int main

I was looking at a sketch and the writer of it used int main instead of void setup and void loop. Why would this be? Any benefits?

Jepaly: I was looking at a sketch and the writer of it used int main instead of void setup and void loop. Why would this be? Any benefits?

Depends on the sketch.

Some might use "main" and a "makefile" to compile projects without using the Arduino-IDE.

Some others might use "main" to avoid TIMER0 being used for providing time counting functions like millis() or micros(), because they want to have an application that uses TIMER0 in a different way and not for milliseconds/microsecond time counting.

Some others perhaps just want to throw out the SerialEvent handling from the Arduino main function, which is using up processing time while hardly being of any use for anyone.

Ask the one who wrote the sketch you saw about his intention!

I'm unable to contact the individual. Will main have a form of void loop? Or will it bypass the loop portion completely

main is the actual thing that's started when you power up the Arduino. But to make life easy Arduino came up with loop() and setup(). In the background your code is wrapped in this (except serial and some more)

void main(){
  setup();

  while(true){
    loop();
  }
}

If you look for main.cpp in your Arduino installation directory, it contains:

int main(void)
{
    init();

    initVariant();

#if defined(USBCON)
    USBDevice.attach();
#endif

    setup();
    
    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }
        
    return 0;
}

which explains how the Arduino IDE environment sets things up.

Jepaly: Or will it bypass the loop portion completely

EVERY C/C++ program is using a main() function, even if you are writing an Arduino sketch in the IDE and main() is unvisible to you.

The Arduino main() function is coded like that:

int main(void)
{
 init();

 initVariant();

#if defined(USBCON)
 USBDevice.attach();
#endif

 setup();
    
 for (;;) {
 loop();
 if (serialEventRun) serialEventRun();
 }
        
 return 0;
}

So in your "sketch" written within the Arduino-IDE you have two options:

1st option: You just write setup() and loop() functions, and the Arduino default "main()" function will call your functions setup() and loop() from the "invisible main()".

2nd option: You write your own main() function and in that case only your own main() function will be used and not the Arduino default "main()" function.

Ok thank you. I think I get it.