Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Void Pointer Usage
#1
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.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)