Cannot check function address

frame frame86 at live.com
Tue May 24 18:54:33 UTC 2022


I have a function slot that may be loaded via a shared library.
I want to check if that function has an address but compiler (DMD 
2.100, Windows) instead tries to invocate the function?

```d
// --- module a:
alias F = extern (C) void function(string param);
F fun = someLibLoad!F("name");

assert(fun !is null); // compiles (also works in runtime)

// --- module b:
import a;

// same code:
//
// error: missing argument for parameter #1: ... with 2.098.1 or
// error: too few arguments, expected `5`, got `0` ... with 2.100
assert(fun !is null);
```

Usually that works fine as shown in module A but for some reason 
not in module B.
Workaround ideas? I tried casting to void* or ptrdiff_t but the 
compiler always tries to call the function -.-


More information about the Digitalmars-d-learn mailing list