3 ms·
> void main() What language is this?
by cbd1984 11y ago
> void main()
What language is this?
- pgaddict 11y agoC, but I've been lazy.
- cbd1984 11y agoNo, it isn't C in any real sense.
- Someone 11y agoIt is valid ISO C, if it isn't running in a hosted environment. http://stackoverflow.com/questions/2108192/what-are-the-valid-signatures-for-cs-main-function http://stackoverflow.com/questions/2108192/what-are-the-vali...: "In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined." So, there, the entry point could have prototype void main(); and if it doesn't, that makes that name available as the name of a user-defined function.
- deleted 11y ago[deleted]
- cbd1984 11y ago> It is valid ISO C, if it isn't running in a hosted environment. Well, if you don't have an OS, a lot of things change. My question comes from all of the C-like Algol-like languages which look like C but... aren't C. You know, like how Java/C# isn't technically one language, but two, for legal reasons.
- kazinator 11y ago> It is valid ISO C, if it isn't running in a hosted environment It is valid ISO C syntax in any environment, which has no meaning according to ISO C. To have meaning in a hosted environment, the implementation must supply one by accepting "void main" as a startup function in addition to the required forms. In a freestanding environment, for the program to have meaning, the freestanding implementation must ... supply one by accepting "void main" as a startup function as one of its implementation-defined startup function forms. It's the same thing: the program is not defined by ISO C, but implementations can give it a local definition of meaning. If both kinds of implementations support "void main(void)" as an extension, they have to documented it, because an implementation must document all extensions. I'm looking at C99, section 4: An implementation shall be accompanied by a document that defines all implementationdefined and locale-specific characteristics and all extensions. So, if "void main(void)" is officially accepted by a freestanding implementation, that means it is one of the implementation-defined startup function forms, and must be documented. If "void main(void)" is officially accepted by a hosted implementation, it constitutes an extension and must be documented. Basically, the status of void main appears identical, whether hosted or not, with regard to the definedness of behavior (as far as ISO C is concerned), and the requirement for documentation if it is supported.