07-03-2007, 03:10 PM
Hello,
I am new to MISRA-C rules and in the code I am working on, there this kind of constructs :
and for instance :
tpl_action is an abstract type (no instance) and tpl_task_activation_action is a concrete type.
The function pointed by action function pointer takes a tpl_action * and casts it to the appropriate concrete type.
I understand rule 45 disallows pointer type casting to avoid memory alignment problems but here the first member of the abstract type is of the same type as the first member of the concrete type.
Is it legal ?
Best regards
I am new to MISRA-C rules and in the code I am working on, there this kind of constructs :
Code:
struct TPL_ACTION {
tpl_action_func action; /**< action function pointer */
};
typedef struct TPL_ACTION tpl_action;
and for instance :
Code:
struct TPL_TASK_ACTIVATION_ACTION {
/* base action */
tpl_action b_desc;
/* task descriptor pointer */
tpl_task *task;
};
typedef struct TPL_TASK_ACTIVATION_ACTION
tpl_task_activation_action ;
tpl_action is an abstract type (no instance) and tpl_task_activation_action is a concrete type.
The function pointed by action function pointer takes a tpl_action * and casts it to the appropriate concrete type.
I understand rule 45 disallows pointer type casting to avoid memory alignment problems but here the first member of the abstract type is of the same type as the first member of the concrete type.
Is it legal ?
Best regards