Function reference accross modules => link error: unresolved external
Adam D. Ruppe
destructionator at gmail.com
Wed May 8 17:02:07 UTC 2019
On Wednesday, 8 May 2019 at 16:20:22 UTC, Robert M. Münch wrote:
> Sometimes a simple thing should be obvious but...
>
> // a.d
> module a;
>
> int otherFunc();
>
> main(){
> otherFunc();
> }
>
>
>
> // myapp.d
> import a;
> int otherFunc(){
> return(1);
> }
Those are two *entirely different* functions, `a.otherFunc` and
`myapp.otherFunc`.
Generally the answer here is "don't do that". Just have module a
`import myapp` and then call otherFunc.
But if you must hack around it - and seriously ask yourself if
this is good design before committing to it - you can slap
`extern(C)` on the `otherFunc` declaraton and definition to force
them to match up in the global namespace.
More information about the Digitalmars-d-learn
mailing list