Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pointer to void
#1
I just want to know when a cast shall be performed between a pointer to void and any type or vice versa?

for example is this code compliance with misra-c?

void* GetNewObject (void);
void SetProperty (void*, uint8_t);

void main (void)
{
void* lpVoid;
OBJECT_T* lpObject;

lpVoid = NULL;
lpObject = NULL;

lpObject = GetNewObject ();
/* there is an explicit cast in
this function from OBJECT_T*
type to void* type, so GetNewObject
return an OBJECT_T* qualifier type */

lpVoid = lpObject;

SetProperty (lpVoid, 4U);

lpObject = lpVoid;

if (lpObject == lpVoid)
{
SetProperty (lpObject, 5U);
}

lpVoid = lpObject;
}
<t>Embedded System</t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)