Writing a (valid) C program without main()

(labs.iximiuz.com)

15 points | by birdculture 2 hours ago ago

6 comments

  • eska an hour ago

    Note 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 an hour ago

    I 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 an hour ago

      >Most interesting C programs violate the standard in some way though.

      Wow, who counted them and decided what is or isn't interesting? And would the interesting programs still be interesting if they didn't violate the standard?

      • asveikau 11 minutes ago

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

      • pechay an hour ago

        All C programs are interesting. The first potentially non-interesting program in C is interesting because it's the first non-interesting one. :)

  • pishpash an hour ago

    This isn't making a C program. It's using C tools and assembly tools to make an executable.