04-08-2015, 09:00 PM
Hi everybody
I'm having a very hard time understanding why the following code gives me two errors regarding rule 11.3.
And in both cases the error is: A cast shall not be performed between a pointer to object type and a pointer to a different object type
The thing here is that both TaskParams and TaskConfig are pointers of the same type that are the struct elements Params and Tasks. I don't understand how ---TaskConfig_t TaskConfig[NUM_TASKS]--- is different from ---TaskConfig_t *Tasks---. They seem similar to me, or, am I messign something?
Thank you very much for helping and I hope this could be explained because I'm really frustrated.
Regards.
I'm having a very hard time understanding why the following code gives me two errors regarding rule 11.3.
Code:
#define NUM_TASKS 3
typedef struct
{
uint32_t *CpuUtilizationPercent;
uint32_t *Counter;
TaskParam_t *Params;
TaskConfig_t *Tasks;
uint8_t NumTasks;
} PPTS_Config_t;
static uint32_t PPTS_CpuUtilizationPercent;
static uint32_t PPTS_Counter;
static TaskParam_t TaskParams[NUM_TASKS];
static TaskConfig_t TaskConfig[NUM_TASKS];
const PPTS_Config_t CnfPPTS =
{
&PPTS_CpuUtilizationPercent,
&PPTS_Counter,
TaskParams, /* MISRA-C rule 11.3 violation */
TaskConfig, /* MISRA-C rule 11.3 violation */
NUM_TASKS
};
The thing here is that both TaskParams and TaskConfig are pointers of the same type that are the struct elements Params and Tasks. I don't understand how ---TaskConfig_t TaskConfig[NUM_TASKS]--- is different from ---TaskConfig_t *Tasks---. They seem similar to me, or, am I messign something?
Thank you very much for helping and I hope this could be explained because I'm really frustrated.
Regards.
<t></t>