4 ms·
Writing a (valid) C program without main()
- eska 3mo agoNote that this is not a “valid” C program according to the standard. The standard allows for freestanding and hosted environments. Freestanding allows for the entry point to be called something else than main, but there are other requirements. See section 4 and 5 of a draft if interested.
- asveikau 3mo agoI think the definition of "valid" may differ. Is this a standard conforming C program? No. Did you use implementation details of your platform to create a program that loads and runs correctly? Sure. Most interesting C programs violate the standard in some way though.
- elpocko 3mo ago[flagged]
- pechay 3mo agoAll C programs are interesting. The first potentially non-interesting program in C is interesting because it's the first non-interesting one. :)
- asveikau 3mo agoI guess what I'm saying is that some common practices are under specified and live in gray areas of the standard, and practicing programmers rely on those behaviors. Sometimes other standards like POSIX cover the gaps.
- pishpash 3mo agoThis isn't making a C program. It's using C tools and assembly tools to make an executable.
- unexpectedpasta 3mo ago[dead]
- general1465 3mo agoIt is a C program. Completely valid, only little bit unorthodox.
- pjmlp 3mo ago> C is the closest you can get to the operating system without writing assembly. Nope, plenty of languages have been offering the same features since JOVIAL in 1958. That is an urban myth spread by folks that never learnt another systems programming language, or computing history.