How to get access to Voldemort / private thingies

Johan Engelen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 18 11:55:00 PDT 2016


On Saturday, 18 June 2016 at 17:50:51 UTC, cy wrote:
> On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote:
>> Without going in too much detail, the problem is that I am not 
>> linking to opaque .o files.
>
> The problem is the compiler has to assume you *might* be 
> linking to opaque .o files, so it can't provide any 
> introspection capabilities. There's no way to tell which 
> "hidden type" that the getObject function is returning, since 
> that's decided in the (possibly opaque) function body.

The function body is not opaque. In my compilation unit, the 
compiler knows it, and that's exactly why I run into troubles. 
For ease of discussion, just pretend the function that returns 
the Voldemort type is in the same file as the user code: let's 
say it's all in one source file.
Just like there is a way to get private types out of structs 
(using .tupleof or the Fields!Strukt[*] thing I pasted above), I 
was hoping there was a way to get a Voldemort type out of a 
function.

This is of course all a big hack. The pragma(mangle,..) thing 
works well, but unfortunately conflicts with the LDC inlining 
improvement I'm working on.
Like you say, I could copy the whole function definition, but it 
would mean copying quite a lot and some more types etc...

- Johan



More information about the Digitalmars-d-learn mailing list