News for hackers. Stuff that matters.
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by friendzis on Thursday January 23, 2025 @04:10AM (#42802205)
`main` is the default entrypoint, with one simple argument to the linker you can change entrypoint symbol to whatever you wish.

You can add `premain` function that calls `main` and set it as an entrypoint, you can implement pre-start logic in main and call main loop later.

This is how any sane program is written anyway: set up environment -> continue with business logic

Re:C stdlib isn't threadsafe and even safe Rust didn't save us by account42 on Thursday January 23, 2025 @06:25AM (#42802959)
main() is not the entry pont, some platform specific CRT is.
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by skissane on Thursday January 23, 2025 @03:02PM (#42807491)
Also, the CRT will call any functions you declare `__attribute__((constructor))` before it calls `main()`
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by dietr1ch on Friday January 24, 2025 @08:33AM (#42812849)
I know I can fool around with crt0, but I'm not sure how much you can really use that if you plan to use libraries that may depend on global `static` things that get created as they are linked in before `main` starts.

Maybe it's possible, but if I need to review every library (and hope they don't break my assumptions later) I think I lost on building this separation in practical way.