summaryrefslogtreecommitdiff
path: root/libphobos/libdruntime/__entrypoint.di
blob: 7bae2388d56662fe6c3f498a243b8eed900647f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* GDC -- D front-end for GCC
   Copyright (C) 2013-2018 Free Software Foundation, Inc.

   GCC is free software; you can redistribute it and/or modify it under
   the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 3, or (at your option) any later
   version.

   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.
*/

/* This module provides the C main() function supplied by the user's program.  */

module __entrypoint;

extern(C):

/* The D main() function supplied by the user's program

   It always has `_Dmain` symbol name and uses C calling convention.
   But D frontend returns its type as `extern(D)` because of Issue 9028.
   As we need to deal with actual calling convention we have to mark it
   as `extern(C)` and use its symbol name.
*/

int _Dmain(char[][] args);
int _d_run_main(int argc, char **argv, void* mainFunc);

/* Substitutes for the C main() function.  Just calls into d_run_main with
   the default main function.  Applications are free to implement their own
   main function and call the _d_run_main function themselves with any main
   function.
*/

int main(int argc, char **argv)
{
    return _d_run_main(argc, argv, &_Dmain);
}

/* This is apparently needed on Solaris because the C tool chain seems to
   expect the main function to be called _main.  It needs both not just one!
*/

version (Solaris)
int _main(int argc, char** argv)
{
    return main(argc, argv);
}