On 07.04.19 14:23, Robert M. Münch wrote:
struct X {
     TYPE a;
     TYPE b;
}


myFunc(X _struct){
     alias a = _struct.a;

     a = myOtherFunc();
}


X myStruct;

myFun(myStruct);


This gives an error: need this for a of type void*

I don't understand why, because all I want is a shortcut the symbol of the parameter.

You can't make an alias to a field of an object. The alias will be made in relation to the type instead. (If that makes sense. I'm not sure how to phrase it best.)

In code, this:

    alias a = _struct.a;

is the exact same as this:

    alias a = X.a;

The instance `_struct` is not part of the alias.

Reply via email to