145
|
1 /* GDC -- D front-end for GCC
|
|
2 Copyright (C) 2013-2020 Free Software Foundation, Inc.
|
|
3
|
|
4 GCC is free software; you can redistribute it and/or modify it under
|
|
5 the terms of the GNU General Public License as published by the Free
|
|
6 Software Foundation; either version 3, or (at your option) any later
|
|
7 version.
|
|
8
|
|
9 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 for more details.
|
|
13
|
|
14 You should have received a copy of the GNU General Public License
|
|
15 along with GCC; see the file COPYING3. If not see
|
|
16 <http://www.gnu.org/licenses/>.
|
|
17 */
|
|
18
|
|
19 /* This module provides the C main() function supplied by the user's program. */
|
|
20
|
|
21 module __entrypoint;
|
|
22
|
|
23 extern(C):
|
|
24
|
|
25 /* The D main() function supplied by the user's program
|
|
26
|
|
27 It always has `_Dmain` symbol name and uses C calling convention.
|
|
28 But D frontend returns its type as `extern(D)` because of Issue 9028.
|
|
29 As we need to deal with actual calling convention we have to mark it
|
|
30 as `extern(C)` and use its symbol name.
|
|
31 */
|
|
32
|
|
33 int _Dmain(char[][] args);
|
|
34 int _d_run_main(int argc, char **argv, void* mainFunc);
|
|
35
|
|
36 /* Substitutes for the C main() function. Just calls into d_run_main with
|
|
37 the default main function. Applications are free to implement their own
|
|
38 main function and call the _d_run_main function themselves with any main
|
|
39 function.
|
|
40 */
|
|
41
|
|
42 int main(int argc, char **argv)
|
|
43 {
|
|
44 return _d_run_main(argc, argv, &_Dmain);
|
|
45 }
|
|
46
|
|
47 /* This is apparently needed on Solaris because the C tool chain seems to
|
|
48 expect the main function to be called _main. It needs both not just one!
|
|
49 */
|
|
50
|
|
51 version (Solaris)
|
|
52 int _main(int argc, char** argv)
|
|
53 {
|
|
54 return main(argc, argv);
|
|
55 }
|
|
56
|