11-01-2007, 09:04 AM
Hi,
I have a question regarding the use of Void pointers.
Rule 11.2 is the rule that applies (Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object or a pointer to void).
My first question is:
How do you define \"a pointer to object\"?
By this, do you mean structure, derived types?
I couldn't see any definition for this in the MISRA text.
My second question is:
This rule allows the conversion of a pointer from one type to void. (i.e. to a NULL_PTR to allow for error checking)
I think that this rule also prohibits the use of a defined void ptr, converting this to point to an array or other obect, is this correct?
i.e. the following is illegal:
void *pv_my_void_ptr = NULL_PTR;
u16 *pu16_my_int_ptr = (u16 *)pv_my_void_ptr;
As this would make the checking of alignment (i.e. Rule 11.4) impossible as well as hiding the original type pointed to?
Many Thanks for your consideration.
Mike.
I have a question regarding the use of Void pointers.
Rule 11.2 is the rule that applies (Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object or a pointer to void).
My first question is:
How do you define \"a pointer to object\"?
By this, do you mean structure, derived types?
I couldn't see any definition for this in the MISRA text.
My second question is:
This rule allows the conversion of a pointer from one type to void. (i.e. to a NULL_PTR to allow for error checking)
I think that this rule also prohibits the use of a defined void ptr, converting this to point to an array or other obect, is this correct?
i.e. the following is illegal:
void *pv_my_void_ptr = NULL_PTR;
u16 *pu16_my_int_ptr = (u16 *)pv_my_void_ptr;
As this would make the checking of alignment (i.e. Rule 11.4) impossible as well as hiding the original type pointed to?
Many Thanks for your consideration.
Mike.