]> git.ipfire.org Git - thirdparty/gcc.git/blob - libphobos/libdruntime/core/internal/entrypoint.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / libphobos / libdruntime / core / internal / entrypoint.d
1 /**
2 This module contains the code for C main and any call(s) to initialize the
3 D runtime and call D main.
4
5 Copyright: Copyright Digital Mars 2000 - 2019.
6 License: Distributed under the
7 $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
8 (See accompanying file LICENSE)
9 Source: $(DRUNTIMESRC core/_internal/_entrypoint.d)
10 */
11 module core.internal.entrypoint;
12
13 /**
14 A template containing C main and any call(s) to initialize druntime and
15 call D main. Any module containing a D main function declaration will
16 cause the compiler to generate a `mixin _d_cmain();` statement to inject
17 this code into the module.
18 */
19 template _d_cmain()
20 {
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 }