Compiling Was: arrays and foreach

David d at dav1d.de
Tue Apr 17 05:11:20 PDT 2012


> 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.

That's not surprising, try to write a C program with no main:

─[ArchBox][/tmp]╼ touch foo.c
─[ArchBox][/tmp]╼ LANG=C gcc foo.c
/usr/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status

You get the linker errors, because there is no entry-point for your 
program, but that has nothing to do with D, it's a common behaviour for 
C, C++, D and other languages.


And the unittest(-switch) is also good relativly good explained at 
http://dlang.org/unittest.html (dlang -> search -> unittest)


More information about the Digitalmars-d-learn mailing list