import issue?

DLearner bmqazwsx123 at gmail.com
Wed Nov 22 16:08:43 UTC 2023


Please,
Why does:

```
// Test module Ex_mod
struct SA {
    int   SAIntFld1;
    int   SAIntFld2;
}

bool AddEle(ref void* StartPtr, SA PayLoad1) {

    import core.stdc.stdlib : malloc;

    struct Ele {
       SA   PayLoad;
       Ele* EleNxtPtr;
       Ele* ElePrvPtr;
    }

    Ele*    ElePtr;
    Ele*  wkElePtr;

    return true;
}

```

imported into:
```
// Test harness

struct SA {
    int   SAIntFld1;
    int   SAIntFld2;
}


void main() {

    import std.stdio: writeln;

    import Ex_mod;

    SA SAVar;
    void* SA_StartPtr = null;

    SAVar.SAIntFld1 = 3;
    SAVar.SAIntFld2 = -5;

    if (AddEle(SA_StartPtr, SAVar)) {
       writeln("Element linked");
    } else {
       writeln("Element not linked");
    }

}
```

Fail with:
```
ex_main.d(21): Error: function `Ex_mod.AddEle(ref void* StartPtr, 
SA PayLoad1)` is not callable using argument types `(void*, SA)`
ex_main.d(21):        cannot pass argument `SAVar` of type 
`ex_main.SA` to parameter `Ex_mod.SA PayLoad1`

```

When eliminating the import via:

```
// Test harness

struct SA {
    int   SAIntFld1;
    int   SAIntFld2;
}

bool AddEle(ref void* StartPtr, SA PayLoad1) {

    import core.stdc.stdlib : malloc;

    struct Ele {
       SA   PayLoad;
       Ele* EleNxtPtr;
       Ele* ElePrvPtr;
    }

    Ele*    ElePtr;
    Ele*  wkElePtr;

    return true;
}


void main() {

    import std.stdio: writeln;

//   import Ex_mod;

    SA SAVar;
    void* SA_StartPtr = null;

    SAVar.SAIntFld1 = 3;
    SAVar.SAIntFld2 = -5;

    if (AddEle(SA_StartPtr, SAVar)) {
       writeln("Element linked");
    } else {
       writeln("Element not linked");
    }

}
```

works correctly?


More information about the Digitalmars-d-learn mailing list