On Thursday, 30 September 2021 at 02:02:19 UTC, Hipreme wrote:
Instead of writing

myFunction = cast(typeof(myFunction))_loadSymbol(_dll, "myFunction");

I could write

loadSymbol!myFunction;

But if no other way is found of doing that, I will do the massive rewriting.

---

void function() x;

void load(void* thing, string name) {
// this lhs cast is the magic, the rhs cast unneeded in reality cuz GetProcAddress returns void* naturally
        * cast(void**) thing = cast(void*) 0xdeadbeef;
}

void main() {
        // no cast here but yes repeated name
        load(&x, "foo");

         // casts needed here just to do the comparison
        assert(cast(void*) x == cast(void*) 0xdeadbeef);
}

---


A little void casting inside the function can do the trick. You will have to pass the name separately though.


im off to bed ttyl

Reply via email to