How minimal I can go using D on GDC?

Iain Buclaw ibuclaw at ubuntu.com
Sun May 12 11:51:31 PDT 2013


On 12 May 2013 18:13, Timo Sintonen <t.sintonen at luukku.com> wrote:

> On Sunday, 12 May 2013 at 15:27:04 UTC, Iain Buclaw wrote:
>
>> On 12 May 2013 15:41, Rel <relmail at rambler.ru> wrote:
>>
>>  Benjamin Thaut, yes I know. but here is an example, if I add a class to
>>> the code like that:
>>>
>>>
>>> module main;
>>>
>>> extern (C) void* _Dmodule_ref = null;
>>> extern (C) void printf(const char*, ...);
>>>
>>> extern (C) void puts(const char*);
>>> extern (C) void exit(int);
>>>
>>> class A {
>>>         int a = 100;
>>>         int b = 200;
>>>
>>> };
>>>
>>> extern (C) void main() {
>>>         scope(exit) {
>>>                 puts("Exiting!");
>>>                 exit(0);
>>>         }
>>>
>>>         A a; printf("%d %d\n", a.a, a.b);
>>> }
>>>
>>>
>> This code won't work.  classes are reference types and need to be
>> initialised with 'new'.  This requires TypeInfo_Class information to
>> do...   You could possible use 'scope A a = new A'.  But again your going
>> into the bounds of needing rtti for the initialiser var to assign it on
>> the
>> stack.
>>
>> Structs would be your friend here...
>>
>
> I have used the option -fno-emit-moduleinfo and got rid of _Dmodule_ref
>

I completely forgot that I put that in.  Well done me *pats own back*.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20130512/47cab82d/attachment.html>


More information about the D.gnu mailing list