Compiling Was: arrays and foreach
Somedude
lovelydear at mailmetrash.com
Tue Apr 17 04:43:28 PDT 2012
Le 17/04/2012 12:19, Mike Parker a écrit :
> On 4/17/2012 4:42 PM, Somedude wrote:
>
>>>
>>> Ali
>>>
>>>
>> Hi Ali,
>>
>> Sorry for hijacking this thread, but since you're around, I hope you'll
>> see this message. As a D beginner, I'm browsing through your book.
>> I wanted to tell you that there is something essential missing in it:
>> how to compile. It's actually quite hard to find it in the official
>> website, and since the first chapters are targetted at complete
>> beginners, I thought it would be nice to add a few lines or pages about
>> compilation, linking, debugging, etc.
>> What do you think ?
>
> In the sidebar at dlang.org, under Documentation, is a link labeled
> "Tutorial". The very first code example shows a minimal program and how
> to compile it.
Well, yes, that's sufficient for "Hello, world", but not for something
barely more complex, i.e a function with a unit test.
In this case, I had to type:
rdmd -unittest --main test.d
Without the --main, I would get linker errors, and couldn't find the
reason for these errors. Happily, someone here explained me that the
effect of the --main flag was to insert a main() function just for this
case.
Now, I see there is a mention of this in http://dlang.org/rdmd.html
But without rdmd, I would compile with dmd, which has no --main switch,
and it would still fail to link, because of lack of main(). The code I
posted wasn't my code, and I knew it had worked, so I assumed it was
correct, I didn't figure out that adding a main() was necessary given
there was a unit test.
And anyway, explaining in the book how to link is a necessary step imho.
This is why I made this page more visible in the Wiki:
http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD
More information about the Digitalmars-d-learn
mailing list