How do I make an extern function?
Simen kjaeraas
simen.kjaras at gmail.com
Tue Jun 29 03:24:42 PDT 2010
BCS <none at anon.com> wrote:
> The issue is that the function called from module a is
> _D1a3fooFZv where the function defined in module b is
> _D1b3fooFZv ('a' <-> 'b') so they aren't the same function. extern(C)
> works because C doesn't mangle names so the function is foo in both
> cases.
I know. I just react to 'extern void foo();' being treated as a
function that must be in a. I would expect extern to indicate it lies
elsewhere in the program.
> You can resolve this by having a a.di file with the extern foo(); in it
> (DMD has a flag to generate such a file for you). OTOH without knowing
> what you are doing, I can't tell if this is the correct solution.
I'm trying to create a framework in which the user may provide his own
foo( ), so the name of module b is impossible to know.
torhu <no at spam.invalid> wrote:
> You could always create a b.di file, if that doesn't defeat the
> purpose.
Jonathan M Davis <jmdavisprog at gmail.com> wrote:
> Um, extern isn't needed in D. All you need to do is make the function
> public and then import the module.
If only life were easy, eh? Module b is user-supplied, so I can't import
it.
--
Simen
More information about the Digitalmars-d-learn
mailing list