Re: Where is TypeInfo_Class.m_init set

2018-08-02 Thread Hakan Aras via Digitalmars-d-learn
On Thursday, 2 August 2018 at 10:54:17 UTC, kinke wrote: Those 4 bytes for the struct is trailing padding, so that the struct is 16 bytes large, a multiple of its 8-bytes alignment (due to the pointer). Classes on the other hand aren't padded (they don't need to be, as there are no contiguous

Re: Where is TypeInfo_Class.m_init set

2018-08-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 August 2018 at 02:52:44 UTC, Hakan Aras wrote: LDC complains about the type of initializer though: onlineapp.d(22): Error: Global variable type does not match previous declaration with same mangled name: _D5bclib3Baz6__initZ onlineapp.d(22):Previous IR type: %bclib.Baz =

Re: Where is TypeInfo_Class.m_init set

2018-08-01 Thread Hakan Aras via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 20:45:11 UTC, kinke wrote: Sorry, scratch that, I forgot the `extern` before the dummy global. After fixing that, I didn't quickly find a solution for referencing the symbol in the .data.rel.ro section (LLVM asm, e.g., `void* getInit() { return __asm!(void*)("movq t

Re: Where is TypeInfo_Class.m_init set

2018-07-31 Thread kinke via Digitalmars-d-learn
Sorry, scratch that, I forgot the `extern` before the dummy global. After fixing that, I didn't quickly find a solution for referencing the symbol in the .data.rel.ro section (LLVM asm, e.g., `void* getInit() { return __asm!(void*)("movq test.C.__init, %rax", "={rax}"); }` doesn't work either).

Re: Where is TypeInfo_Class.m_init set

2018-07-31 Thread kinke via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 01:16:29 UTC, Hakan Aras wrote: I was hoping it would be possible without tinkering with the compiler, but it doesn't seem to be the case. I've been playing around with LDC. There is an init symbol for classes, which is normally used as payload for the ClassInfo's

Re: Where is TypeInfo_Class.m_init set

2018-07-31 Thread Hakan Aras via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 03:42:15 UTC, Mike Franklin wrote: I would also like to be able to use `extern(C++)` classes without the runtime, but I haven't been able to allocate any time to it yet. If you're trying to use `extern(C++)` classes with betterC, and the compiler is complaining ab

Re: Where is TypeInfo_Class.m_init set

2018-07-30 Thread Mike Franklin via Digitalmars-d-learn
On Monday, 30 July 2018 at 22:40:21 UTC, Hakan Aras wrote: I'm trying to use extern(C++) classes with -betterC and I would like to initialize their members properly. I would also like to be able to use `extern(C++)` classes without the runtime, but I haven't been able to allocate any time to

Re: Where is TypeInfo_Class.m_init set

2018-07-30 Thread Hakan Aras via Digitalmars-d-learn
If anyone stumbles upon this thread and wants to do the same thing, this article has some solutions: https://theartofmachinery.com/2018/05/27/cpp_classes_in_betterc.html Not perfect, but at least it's a start.

Re: Where is TypeInfo_Class.m_init set

2018-07-30 Thread Hakan Aras via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 00:29:45 UTC, Mike Franklin wrote: I don't think it is set in druntime, but rather directly emitted to the binary by the compiler as part of the object code generation. I'm not sure if this is right, but check That makes sense. I was hoping it would be possible

Re: Where is TypeInfo_Class.m_init set

2018-07-30 Thread Mike Franklin via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 00:29:45 UTC, Mike Franklin wrote: I'm not sure if this is right, but check https://github.com/dlang/dmd/blob/792fe5379af310cbd9348eca910cd5f8889d57ac/src/dmd/toobj.d#L368 Actually, this looks more like what you're looking for: https://github.com/dlang/dmd/blob/79

Re: Where is TypeInfo_Class.m_init set

2018-07-30 Thread Mike Franklin via Digitalmars-d-learn
On Monday, 30 July 2018 at 22:40:21 UTC, Hakan Aras wrote: Sorry if this is the wrong category. Where in the druntime is m_init of TypeInfo_Class set? I'm trying to use extern(C++) classes with -betterC and I would like to initialize their members properly. I don't think it is set in druntim

Where is TypeInfo_Class.m_init set

2018-07-30 Thread Hakan Aras via Digitalmars-d-learn
Sorry if this is the wrong category. Where in the druntime is m_init of TypeInfo_Class set? I'm trying to use extern(C++) classes with -betterC and I would like to initialize their members properly.