r/programming • u/iximiuz • Jul 25 '26
Writing a (valid) C program without main()
https://labs.iximiuz.com/tutorials/c-program-without-main-a1eea557
193
Upvotes
r/programming • u/iximiuz • Jul 25 '26
View all comments
9
u/_kst_ Jul 26 '26
You cannot write a valid portable C program for a hosted implementation without a
mainfunction. The language requires it. "The function called at program startup is namedmain."As the article demonstrates, there are ways to work around this if you play some system-specific tricks, but they will work only for some particular implementations.
I can replace a portable C
hello, worldprogram with anecho hello, worldshell command, but then I'm no longer programming in C.The article does provide some interesting information about how some particular C implementations work, but the title is overblown.