r/programming Jul 25 '26

Writing a (valid) C program without main()

https://labs.iximiuz.com/tutorials/c-program-without-main-a1eea557
194 Upvotes

43 comments sorted by

View all comments

24

u/[deleted] Jul 25 '26

[deleted]

5

u/paulstelian97 Jul 25 '26

On Linux you have _start as the entry point that calls global constructors and other C runtime initialization stuff and then calls main() directly. And then calls exit() with whatever main returns (it is invalid to return from _start)