Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
FYI, I didn't realize this (but just figured it out), C main *used* to be in druntime, but it's now generated by the compiler. See here: https://github.com/D-Programming-Language/dmd/blob/master/src/mars.c#L236 True. But it is compiler-dependent. GDC actually still defines C main in the

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike Parker via Digitalmars-d-learn
On 5/22/2015 10:26 PM, Suliman wrote: Really hard to understand... So what what would call at first ? extern(C) int main() or int _Dmain() Your D programs have multiple layers. There is the C runtime, DRuntime, and your program code. The C runtime is at the bottom. When the program

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
Could you explain what mean C main inside the runtime. I thought that is only one main is possible. And why it's named *ะก* main D is not C-translated language. Same question is about _Dmain -- what is it? If I will call this() before main? What it will be? Will it run before main?

Re: What happens when you launch a D application ?

2015-05-23 Thread Suliman via Digitalmars-d-learn
Every D program is started as if it were a C program. Why is so necessary? What about C++ and other languages? Does they have more then one main? Why it's more than one main is needed? Why D apps can't start with single main?

Re: What happens when you launch a D application ?

2015-05-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/05/2015 10:57 p.m., Suliman wrote: Every D program is started as if it were a C program. Why is so necessary? What about C++ and other languages? Does they have more then one main? Depends on the implementation. I believe Visual C++ does. But it is used like D's to allow it to

Re: What happens when you launch a D application ?

2015-05-23 Thread Mike via Digitalmars-d-learn
On Saturday, 23 May 2015 at 10:57:22 UTC, Suliman wrote: Every D program is started as if it were a C program. Why is so necessary? It's not actually necessary. You could implement the `_start` function in your D program. Here's a D program without any C runtime, D runtime, or main.

Re: What happens when you launch a D application ?

2015-05-22 Thread John Colvin via Digitalmars-d-learn
On Friday, 22 May 2015 at 06:36:27 UTC, Suliman wrote: On SO[1] I got next answer: What happens when you launch a D application ? The entry point is a C main inside the runtime, which initialize it (the runtime), including module constructor, run the unittest (if you've compiled with

Re: What happens when you launch a D application ?

2015-05-22 Thread John Colvin via Digitalmars-d-learn
On Friday, 22 May 2015 at 11:13:43 UTC, Suliman wrote: Am I right understand that that: 1. every App start from main() 2. Dmain is function that run after main is started and it's run GC, unit-tests and so on? Not really, it depends what you mean by main, the function called main that you

Re: What happens when you launch a D application ?

2015-05-22 Thread John Colvin via Digitalmars-d-learn
On Friday, 22 May 2015 at 11:51:01 UTC, John Colvin wrote: On Friday, 22 May 2015 at 11:13:43 UTC, Suliman wrote: Am I right understand that that: 1. every App start from main() 2. Dmain is function that run after main is started and it's run GC, unit-tests and so on? Not really, it depends

Re: What happens when you launch a D application ?

2015-05-22 Thread Suliman via Digitalmars-d-learn
Am I right understand that that: 1. every App start from main() 2. Dmain is function that run after main is started and it's run GC, unit-tests and so on?

Re: What happens when you launch a D application ?

2015-05-22 Thread Suliman via Digitalmars-d-learn
Really hard to understand... So what what would call at first ? extern(C) int main() or int _Dmain()

Re: What happens when you launch a D application ?

2015-05-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 May 2015 at 13:26:32 UTC, Suliman wrote: So what what would call at first ? The operating system starts the program Then the extern(C) int main() gets called. Then the _Dmain gets called.

Re: What happens when you launch a D application ?

2015-05-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/22/15 2:36 AM, Suliman wrote: On SO[1] I got next answer: What happens when you launch a D application ? The entry point is a C main inside the runtime, which initialize it (the runtime), including module constructor, run the unittest (if you've compiled with -unittest), then call your