1185029Spjd/**
2185029Spjd This module contains the code for C main and any call(s) to initialize the
3185029Spjd D runtime and call D main.
4185029Spjd
5185029Spjd  Copyright: Copyright Digital Mars 2000 - 2019.
6185029Spjd  License: Distributed under the
7185029Spjd       $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
8185029Spjd     (See accompanying file LICENSE)
9185029Spjd  Source: $(DRUNTIMESRC core/_internal/_entrypoint.d)
10185029Spjd*/
11185029Spjdmodule core.internal.entrypoint;
12185029Spjd
13185029Spjd/**
14185029SpjdA template containing C main and any call(s) to initialize druntime and
15185029Spjdcall D main.  Any module containing a D main function declaration will
16185029Spjdcause the compiler to generate a `mixin _d_cmain();` statement to inject
17185029Spjdthis code into the module.
18185029Spjd*/
19185029Spjdtemplate _d_cmain()
20185029Spjd{
21    extern(C)
22    {
23        int _d_run_main(int argc, char **argv, void* mainFunc);
24
25        int _Dmain(char[][] args);
26
27        int main(int argc, char **argv)
28        {
29            return _d_run_main(argc, argv, &_Dmain);
30        }
31
32        // Solaris, for unknown reasons, requires both a main() and an _main()
33        version (Solaris)
34        {
35            int _main(int argc, char** argv)
36            {
37                return main(argc, argv);
38            }
39        }
40    }
41}
42