mixin issue

DLearner bmqazwsx123 at gmail.com
Wed Nov 29 13:31:14 UTC 2023


The code:

```
void main() {

    struct SB {
       char  SBChrFld1;
       char  SBChrFld2;
       int   SBIntFld1;
       int   SBIntFld2;
    }
    SB  SBVar;

    SB* wkSBPtr;


    void* StartPtr1 = null;

    mixin(mxnDelMbr("StartPtr1", "wkSBPtr"));
    return;
}

string mxnDelMbr()(string strStartPtr, string strPLPtr) {
    return `(void* StartPtr, typeof(` ~ strPLPtr ~ `) PLPtr) {

    }(` ~ strStartPtr ~ `,` ~ strPLPtr ~ `)`;
}
```
Fails with:

```
Error: found `End of File` when expecting `;` following statement
```

If an extra ; is added:
```
    }(` ~ strStartPtr ~ `,` ~ strPLPtr ~ `);`;
```

it works but doesn't seem correct.
Further, example above cloned from several other similar 
examples, which
not only work, but if ';' introduced in corresponding place, dmd 
complains with
empty statement deprecation.
FWIW only difference identified between successful examples and 
this one,
is that other functions all return something, this one does not.

Suggestions?


More information about the Digitalmars-d-learn mailing list