Issue using pointers
Hello,
can someone help to identify where is the issue using pointers? The code example is below.
On line 36: workMode->current = workMode->intend;
It's not overwriting/changing the value.
If I change it to like this:
*workMode->current = *workMode->intend;Then, I'm getting an error:
error: invalid type argument of unary '*' (have 'int')Code example:
/* Enum */
typedef enum
{
enWorkMode_0 = 0,
enWorkMode_1 = 1,
enWorkMode_2 = 2,
enWorkMode_3 = 3,
} WorkingModes_e;
/* Structure */
typedef struct
{
WorkingModes_e current;
WorkingModes_e intend;
} WorkModeObj_t;
/* Variable */
WorkModeObj_t workModeObj;
/* Declare */
void IndicationCheck(WorkModeObj_t *workMode);
/* Main */
int main(void)
{
workModeObj.current = enWorkMode_0;
workModeObj.intend = enWorkMode_1;
IndicationCheck(&workModeObj);
}
/* Function */
void IndicationCheck(WorkModeObj_t *workMode)
{
workMode->current = workMode->intend;
}Using an online C compiler, it works. The link is here.
https://onlinegdb.com/LmREICaYl
Working with STM32CubeIDE v1.7.0 and MCU: STM32G0 series.