Trying (and Failing) at Programming with VSCode

Hey all, apologies if this isn't the place to post this, but I'm running into some issues with programming an Arduino Uno with VSCode. My reason for using VSCode rather than the Arduino IDE is that I'm more accustomed to using a main function rather than setup and loop, and would prefer not to use the latter.

#include <Arduino.h>

int main(){
    pinMode(LED_BUILTIN, OUTPUT);
    while (true){
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);
    }
}

When I upload the above code, the Arduino essentially only turns the LED on. If I reverse the order, i.e. low to high rather than high to low, it turns the LED off. Is this an issue with how I'm configuring this, or an issue with the VSCode extension, or something else?

EDIT: I am an idiot and didn't realize that init() was needed before doing anything within main. If anyone wants to explain what exactly init() does to prevent the code being essentially locked on that first line after the while(true), I'd appreciate that. For anyone who's curious, this is my current code after fixing my mistake:

#include <Arduino.h>

int main(){
    init();
    pinMode(LED_BUILTIN, OUTPUT);
    while (true){
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);
    }
}

Is that the complete listing of the code?
Is it that true becomes false?

That's all the code that I wrote. My guess is that maybe I'm missing other functions that would turn some sort of watchdog timer off? I just noticed I forgot init, so maybe that's a reason?

Update: it was the lack of the init() function, that's the error I made. I still haven't figured out exactly why it didn't progress past the first statement after the while(true), but that's why it wasn't working.

Init() starts up the timer that is used to implement delay(). No initialization, the timer won’t be running, and delay() will wait forever for it to advance…

There are probably better reasons.

You can use main() in your own programs. main() is secretly distantly declared in such a way as to be over-ridable (forget technical term)

Simply declare your own, viz:

int main()
{
    // knock yourself out, you got the main program
}

As you have learned, you 'll want to call init(). :expressionless:

a7