A
ajaybgr
Not sure if this is the right place or OT.
One of the Parasoft coding guidelines (which I am using for current project) is
"Do not cast pointers to functions to pointers to primitive types [CODSTA-09-3]"
EXAMPLE(from parasoft document):
void Foo(char *ptrC)
{
*ptrC = 0;
return;
}
void f()
{
void *ptrV = 0;
void (*funPtr) (char*) = 0;
funPtr = &Foo;
ptrV = (void*)funPtr; // Violation of the rule and raise error
return;
}
I can see why it is a bad idea not to write code this way.
But can any one explain where this kind of code is useful?
(imo, to be a guideline it must have been used/misused a lot)
Where casting a function pointer to primitive type makes sense?
Sorry if this is too silly, my mind seems to have hit a wall today.
Regards
Ajay
One of the Parasoft coding guidelines (which I am using for current project) is
"Do not cast pointers to functions to pointers to primitive types [CODSTA-09-3]"
EXAMPLE(from parasoft document):
void Foo(char *ptrC)
{
*ptrC = 0;
return;
}
void f()
{
void *ptrV = 0;
void (*funPtr) (char*) = 0;
funPtr = &Foo;
ptrV = (void*)funPtr; // Violation of the rule and raise error
return;
}
I can see why it is a bad idea not to write code this way.
But can any one explain where this kind of code is useful?
(imo, to be a guideline it must have been used/misused a lot)
Where casting a function pointer to primitive type makes sense?
Sorry if this is too silly, my mind seems to have hit a wall today.
Regards
Ajay