AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  function pointer is not initializing to NULL

    Posted Tue April 15, 2008 06:18 AM

    Originally posted by: SystemAdmin


    Hi,

    I'm using AIX 5.1 and gcc 4.0 version to build my software. Here I'm finding some problem in runtime.
    Here we have static function pointer that is initialized to NULL. Here is the below cases...

    static int (*retrivalFunc)(char *attr, char *option, returnCode *codePtr, char *buf) = NULL;

    sampleFunc() {

    if (attRetrivalfunc != NULL) {
    return(retrivalFunc(attName, dataBuf,codePtr, msg));
    }
    }

    Here at run time for the first only directly its coming to this if loop (ie. !=NULL case), and causing problem.
    But if I remove the NULL initialization, its working fine. I think 'static' will initialize. But why this is not initializing if I explicitly do? Is this problem with AIX environment or gcc? Thanks for any suggestion!
    Thanks & Regards,
    Sharath.
    #AIX-Forum


  • 2.  Re: function pointer is not initializing to NULL

    Posted Tue April 15, 2008 10:40 AM

    Originally posted by: SystemAdmin


    same result when you compile without optimization?
    #AIX-Forum


  • 3.  Re: function pointer is not initializing to NULL

    Posted Wed April 16, 2008 01:22 AM

    Originally posted by: SystemAdmin


    yeah, without -O option also is not working. If i will not initialize this static variable to NULL, then its working on AIX.I think static will automatically initialize to NULL, but explicit initialization to NULL is not working in AIX.
    But this code is working fine in linux.
    #AIX-Forum