Am 28.03.2011 19:48, schrieb Andrew Wiley:
On Mon, Mar 28, 2011 at 12:34 PM, maarten van damme
<[email protected]> wrote:
Thanks to everyone, I got it to compile :D
Still don't get the point of a lib file. I'm used to program java and there
you can compile to a jar-libary, a lib in d is obviously not the same.
In a machine-compiled language, a library just contains straight
binary, and you need a header or an import file (di) to tell the
compiler exactly what code is in that library. This is because unlike
Java, where type information is preserved in bytecode,
machine-compiled code loses a lot of type information during the
transition from code to binary. For example, if I have void add(int a,
uint b) and I compile it, I can no longer tell you that a and b have
different types.
At least, this is how I understand it.
AFAIK you can't get any parameter type from just-binary. The code in
there just expects the stack to have a certain structure and fullfil
certain consitions. If these conditions are not fullfilled it'll probaly
segfault.
Because D (like C++ and unlike C) allows overloading the same name on
different parameter types, this information has to be put into the name
(mangling) to avoid name clashes for the linker.
Mafi
PS: Just a thought of mine: You should be theoretically be able
regenereate function signatures from mangled names. Maybe someone could
such a tool.