Moved from Entry point/new edit

I have moved this page from it Entry point/new as requested. It includes material originally added to the page now at Talk:Entry point/old. A history merge seems impractical, so I have left that page in that location. JPD (talk) 15:41, 9 March 2007 (UTC)Reply

Entry point is really __start() edit

This page says that the entry point to a C program is main(), and phrases this as though this is the only possibility. Last I heard, the default entry point for most C compilers is __start(), and it's always customizable with a linker option. main() is usually called from within __start(), I believe. Xezlec (talk) 17:21, 10 January 2008 (UTC)Reply

This contradicts everything I've learned in software engineering over the past 20+ years. All references on C and C++ I've read have always stated that the main() function is the entry point for every C/C++ application. They've never stated that it's a linker option. If it is, calling main() from some __start() function (which I've never heard of) is so commonplace that it has made main() the de facto entry point for every C and C++ application. This also goes for Java, BTW, and C#. — Frεcklεfσσt | Talk 13:01, 7 May 2014 (UTC)Reply
Hello there! Please have a look at this explanation, and at this thread – those should shed some light regarding how _start() relates to main(). In a few words, main() is the high-level entry point, while _start() is the low-level entry point. — Dsimic (talk | contribs) 06:16, 8 May 2014 (UTC)Reply
Thanks, Dsimic. But that really demonstrates that main() is the customary and default entry point for a program. Very few programmers are going to redirect the linker to use another method as the program's entry point. And as you say, main() is the high-level entry point for the program, while _start() is the low-level entry point. And in this case, the high-level language is C, not assembly. I don't think we want to explain how C works at an assembly level, just as we don't explain how computers work from the perspective of carefully organized sand. Your response doesn't argue that we should, so I assume we are on the same page, and thanks again for the links. — Frεcklεfσσt | Talk 14:23, 8 May 2014 (UTC)Reply
You're welcome. Totally agreed, there's no point in going into that fine implementation-specific details in a Wikipedia article, especially in such a short article – if the article was like five times longer, I'd vote for including such info. At the same time, if someone needs or wants to go as low as dealing with _start(), I doubt he/she will seek for more info on Wikipedia. :) However, there's now a link in Entry point § External links section, for everyone who's interested in such things. — Dsimic (talk | contribs) 16:03, 8 May 2014 (UTC)Reply

Long jump? edit

"[...] an entry point is a memory address, corresponding to a point in the code of a computer program which is intended as destination of a long jump, be it internal or external."

What is a long jump, and what is the difference between an internal long jump and an external long jump (or internal point in code/external point in code)? Thanks, --Abdull (talk) 18:46, 30 January 2010 (UTC)Reply

Exit point? edit

There are mentions throughout the computer science articles of not only entry points but exit points as well. It seems they should be described together, and in terms of both entire programs and single functions. For now I'm going to redirect Entry and exit points here. --Jesdisciple (talk) 02:53, 13 June 2010 (UTC)Reply

Extensive information loss during merge edit

It seems to me that a regression during the move/merge from Main function to Entry point took place such that very little information was actually merged, namely, all the information after the first sentence. See this revision for main()-like entry points [1] or this revision for an extensive list of entry points [2]. One could actually restore with very little effort or information duplication the latest of these revision of the old article to its original location while linking 'main function' in the first sentence of that article to Entry point, and if so desired placing the removed entries to this article, perhaps with a see also template pointing to Main function at the top of its new section and/or linking to it where main currently appears in the article. As one could write quite a lot about int main(...) in particular and its variants outside of Entry point, it saddens me that we've effectively removed nearly all specific information about something you'd learn in programming 101, i.e. as it stands Entry point and the redirection at Main function provide very little technical information that would be of use to someone working or who wants to work in the field, such as my kids, resulting in pointless and avoidable trips outside wikipedia had the article(s) been more comprehensive. tldr I suggest a five minute rework of overlooked unmerged information back into the wikipedia mainline. --123.211.133.251 (talk) 05:29, 12 May 2014 (UTC)Reply

Hello there! According to the history of Main function article and its talk page, a substantial part of its content was deleted prior to the merger (see the Talk:Main function § Languages that don't use main discussion), while it's unclear why none of that (or remaining) content was merged into Entry point later. However, thank you for pointing that out, and the content is now restored into the Entry point article – please check it out. — Dsimic (talk | contribs) 18:45, 12 May 2014 (UTC)Reply

Basic Block edit

Added link to this article in the Basic block. The article is now essentially about main in various languages. Maybe we should add something regarding the more general meaning. Striepan (talk) 13:45, 9 June 2014 (UTC)Reply

int main(void) edit

Does not work on all compilers. Those using calling sequences where the compiler cleans up the arguments in the return path rather than the caller will break - eg bcc in some modes. 86.11.47.92 (talk) 14:04, 2 March 2016 (UTC)Reply

Int main listed at Redirects for discussion edit

 

An editor has asked for a discussion to address the redirect Int main. Please participate in the redirect discussion if you wish to do so. — Arthur Rubin (talk) 10:57, 19 May 2019 (UTC)Reply

A Commons file used on this page or its Wikidata item has been nominated for deletion edit

The following Wikimedia Commons file used on this page or its Wikidata item has been nominated for deletion:

Participate in the deletion discussion at the nomination page. —Community Tech bot (talk) 04:08, 18 May 2023 (UTC)Reply

Saying that execution starts at main is incorrect; in its current form this article is sabotage. edit

In particular, in C++ a lot happens before main is called, including dynamic initialization of namespace scope variables.

Which if you want can present text.

Likewise a lot happens after main returns (if it does), including calls of destructors for static variables, execution of any installed exit handlers, and closing of file descriptors.

---

Example C++ program counter example to the incorrect assertions in the article:

    #include <stdio.h>

    struct Foo
    {
        Foo() { puts( "Before `main`." ); }
        ~Foo() { puts( "After `main`." ); }
    };

    Foo foo;

    auto main() -> int { puts( "In `main`." ); }

Output:

Before `main`.
In `main`.
After `main`.

If execution started at main, as the article erroneously asserts, then in particular the first output line could only be presented if the compiler inserted additional code in main to call static initialization.

That's a poor mental model and it's not how things actually work.

Contrary to some incompetent's comment earlier, specifying the (actual) entry point is of practical utility, because Microsoft tools artificially couple their defaults with choice of entry point.

The entry point one specifies is not main or an alternative, and doing that would only yield general Undefined Behavior. With the first and last output lines above not displayed. It would be nice if Wikipedia stopped publishing articles by complete incompetents.

- Alf 77.16.74.79 (talk) 14:59, 7 July 2023 (UTC)Reply