On Tuesday, 17 April 2012 at 12:11:21 UTC, David wrote:
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)
Yeah I understand, but I thought that by writing unit tests, I
would implicitly add an entry point, but now I see how dumb an
idea that is.