function pointer is not initializing to NULL
Georg Lohrer
pacco@tropezien.de
Tue Apr 15 17:11:00 GMT 2008
sharathyd wrote:
> static int (*retrivalFunc)(char *attr, char *option, returnCode *codePtr,
> char *buf) = NULL;
>
> sampleFunc() {
>
> if (attRetrivalfunc != NULL) {
> return(retrivalFunc(attName, dataBuf,codePtr, msg));
> }
> }
With your statement you will not dereference the function pointer, but
interpret its location as call to a function.
I would prefer using something like:
if (NULL != retrievalFunc) {
return ((* retrievalFunc)(attName, dataBuf, codePtr, msg));
}
Georg
More information about the Gcc-help
mailing list