How do I make an extern function?
torhu
no at spam.invalid
Mon Jun 28 18:34:41 PDT 2010
On 29.06.2010 02:51, Simen kjaeraas wrote:
> ////////////////////
> module a;
>
> extern void foo( );
>
> void bar( ) {
> foo( );
> }
> ////////////////////
> module b;
>
> import std.stdio;
>
> void foo( ) {
> writeln( "Hi!" );
> }
> ////////////////////
>
> The above does not work (Error 42: Symbol Undefined _D1a3fooFZv). Adding
> extern to foo in module b changes nothing. extern( C ) works, but seems
> like a hack. Better ideas?
Using extern (C) is the only way I've seen this done. I don't know of
any way to make the symbols match up otherwise. There's probably some
hack that works, but is uglier than the more straightforward solutions.
You could always create a b.di file, if that doesn't defeat the purpose.
More information about the Digitalmars-d-learn
mailing list