Can dmd compile with my own runtime library?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Aug 23 05:20:03 PDT 2007


Huang F Guan wrote:
> I wrote an object.d, see below:
> 
> module object;
> 
> 
> /// Standard boolean type.
> alias bool bit;
> 
> /**
> * An unsigned integral type large enough to span the memory space. Use for
> * array indices and pointer offsets for maximal portability to
> * architectures that have different memory address ranges. This is
> * analogous to C's size_t.
> */
> alias ulong size_t;
> 
> /**
> * A signed integral type large enough to span the memory space. Use for
> * pointer differences and for size_t differences for maximal portability to
> * architectures that have different memory address ranges. This is
> * analogous to C's ptrdiff_t.
> */
> alias long ptrdiff_t;
> 
> alias ulong hash_t;

The above three are the definitions DMD uses in a "version(X86_64)" 
block, but since it doesn't yet even support 64-bit code this isn't ever 
used by DMD itself. DMD uses
---
     alias uint size_t;
     alias int ptrdiff_t;
     alias uint hash_t;
---
(Though the last one is probably harmless)

[snip lots]
> 
> =========END=========
> I used DMD to compile it, a fatal error occured and the DMD-self exited.

You forgot to copy over (and port where necessary, which isn't much) the 
TypeInfo* classes. They need (replacements for) std.string.cmp, 
std.string.toString(size_t), memcmp and memcpy. And you'll need dynamic 
memory allocation to be implemented for TypeInfo_StaticArray.swap, but 
it deletes allocated memory (if any) at the end so a GC isn't required.



But like I said, I found it easier to just use Tango :).



More information about the Digitalmars-d mailing list