The more important question than the left and right values is: Is it stored in the stack GOBJ or a pointer to GOBJ? From the declaration of GOBJ* st, it seems that you want to store GOBJ, and from the way of calling malloc, it seems that you want to store GOBJ*, and then it becomes confusing.
If you want to store a pointer, then st needs to be declared as GOBJ** st, and malloc does not need to be cast. Then the sentence of pushing onto the stack can be written in array notation:
Tips you that st->st + st->top is not a legal lvalue, st->st + st->top is just a value, and the lvalue should be a referenceable address.
FromWikipedia
The lvalue has a definite memory address that can be obtained. This means that an lvalue can be a variable or the result of dereferencing a pointer to a specific memory address. For example, the C language expression (4 + 9), when executed, the computer generates an integer value 13, but because the program does not explicitly specify how this 13 is stored in the computer, this expression generates an rvalue. On the other hand, if a C program declares a variable x and assigns x the value 13, then the expression (x) evaluates to 13 and is an lvalue.
The more important question than the left and right values is: Is it stored in the stack
GOBJ
or a pointer toGOBJ
? From the declaration ofGOBJ* st
, it seems that you want to storeGOBJ
, and from the way of callingmalloc
, it seems that you want to storeGOBJ*
, and then it becomes confusing.If you want to store a pointer, then
st
needs to be declared asGOBJ** st
, andmalloc
does not need to be cast. Then the sentence of pushing onto the stack can be written in array notation:Tips you that
st->st + st->top
is not a legal lvalue,st->st + st->top
is just a value, and the lvalue should be a referenceable address.FromWikipedia
How about you try this