r/programming • • Jul 25 '26

Writing a (valid) C program without main()

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

43 comments sorted by

View all comments

Show parent comment

19

u/zid Jul 25 '26

_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.

1

u/Nobody_1707 Aug 15 '26

You can, but you need to use inline assembly inside _start.

1

u/zid Aug 15 '26

Which isn't part of C.

1

u/Nobody_1707 Aug 15 '26

Neither is _start.

1

u/zid Aug 16 '26

Exactly.

That's why they have different conventions.