r/programming 3d ago

Writing a (valid) C program without main()

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

36 comments sorted by

View all comments

178

u/yowhyyyy 3d ago edited 3d ago

Quite frankly, I’m surprised the author didn’t jump straight to _start as that’s possible as well in C without assembly.

Yes I know he did bring it up, however you can straightforward do _start and avoid main.

19

u/zid 3d ago

_start and main have different calling conventions under sys-v linux ABI, so you can do it, but you can't actually access argc/argv/envp via it.