void pointers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bcpkh

    void pointers

    Hello All

    Hope someone can help me, please note that at first this might look as
    if it is posted to the wrong group but if you ignore the specifics I
    think it is general pointer referencing issue.

    I am building a plug-in library and is passed, according to the
    documentation the following;

    'A pointer to the OCI environment handle and server context handle are
    supplied via elements zero and one of ociEnvInfo respectively.
    Implementations are free to ignore this parameter, and should do so
    unless it is intended to use the Oracle connection of the calling
    process.'

    void init(void *ociEnvInfo )

    What I have tried is the following;

    OCIEnv *envhp; /*OCI environment handle*/
    OCISvcCtx *svchp; /*Server context handle*/

    void init(void *ociEnvInfo) {

    envhp = (OCIEnv*)ociEnv Info[0];
    svchp = (OCISvcCtx*)oci EnvInfo[1];

    }

    This compiles fine :-) but I keep on getting an OCI_INVALID_HAN DLE
    error which means I am probably not referencing the passed pointers
    correctly.

    Can someone please point me in the right direction.

    Thank you,

    B

    PS: Running HP-UX on Itanium


  • santosh

    #2
    Re: void pointers

    bcpkh wrote:
    Hello All
    >
    Hope someone can help me, please note that at first this might look as
    if it is posted to the wrong group but if you ignore the specifics I
    think it is general pointer referencing issue.
    >
    I am building a plug-in library and is passed, according to the
    documentation the following;
    >
    'A pointer to the OCI environment handle and server context handle are
    supplied via elements zero and one of ociEnvInfo respectively.
    Implementations are free to ignore this parameter, and should do so
    unless it is intended to use the Oracle connection of the calling
    process.'
    >
    void init(void *ociEnvInfo )
    This is a syntax error.
    What I have tried is the following;
    >
    OCIEnv *envhp; /*OCI environment handle*/
    OCISvcCtx *svchp; /*Server context handle*/
    >
    void init(void *ociEnvInfo) {
    >
    envhp = (OCIEnv*)ociEnv Info[0];
    svchp = (OCISvcCtx*)oci EnvInfo[1];
    Try:

    envhp = ((OCIEnv*)ociEn vInfo)[0];
    svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
    >
    }
    >
    This compiles fine :-) but I keep on getting an OCI_INVALID_HAN DLE
    error which means I am probably not referencing the passed pointers
    correctly.
    >
    Can someone please point me in the right direction.
    >
    Thank you,
    >
    B
    >
    PS: Running HP-UX on Itanium

    Comment

    • bcpkh

      #3
      Re: void pointers

      Hello Santosh

      I gave your suggestion a try but my compiler returns the following
      error;

      error #2852: expression must be a pointer to a
      complete object type
      envhp = ((OCIEnv*)ociEn vInfo)[0];
      ^

      error #2852: expression must be a pointer to a
      complete object type
      svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
      ^
      Any ideas?
      This is a syntax error.
      >
      What I have tried is the following;
      >
      OCIEnv                        *envhp; /*OCI environment handle*/
      OCISvcCtx             *svchp; /*Server context handle*/
      >
      void init(void *ociEnvInfo) {
      >
        envhp = (OCIEnv*)ociEnv Info[0];
        svchp = (OCISvcCtx*)oci EnvInfo[1];
      >
      Try:
      >
        envhp = ((OCIEnv*)ociEn vInfo)[0];
        svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
      >

      Comment

      • blargg

        #4
        Re: void pointers

        In article <g78rnd$47u$1@r egistered.motza rella.org>,
        santosh <santosh.k83@gm ail.comwrote:
        bcpkh wrote:
        [...]
        'A pointer to the OCI environment handle and server context handle are
        supplied via elements zero and one of ociEnvInfo respectively.
        Implementations are free to ignore this parameter, and should do so
        unless it is intended to use the Oracle connection of the calling
        process.'
        [...]
        OCIEnv *envhp; /*OCI environment handle*/
        OCISvcCtx *svchp; /*Server context handle*/

        void init(void *ociEnvInfo) {

        envhp = (OCIEnv*)ociEnv Info[0];
        svchp = (OCISvcCtx*)oci EnvInfo[1];
        >
        Try:
        >
        envhp = ((OCIEnv*)ociEn vInfo)[0];
        svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
        (which also gives an error)

        Sounds like init is supposed to take a void**:

        void init(void **ociEnvInfo) {

        envhp = ociEnvInfo[0];
        svchp = ociEnvInfo[1];
        }

        If for some reason it's misdeclared to take a void* in the interface,
        then make a local variable that's a cast of the parameter:

        void init(void *param) {

        void **ociEnvInfo = param;
        envhp = ociEnvInfo[0];
        svchp = ociEnvInfo[1];
        }

        Since this is C, there's no need to do any pointer casts as all the
        source operands are void*.

        Comment

        • Ike Naar

          #5
          Re: void pointers

          In article <02bed960-402b-4866-9d73-743e721cef47@x3 5g2000hsb.googl egroups.com>,
          bcpkh <vanheerden.bra am@gmail.comwro te:
          >'A pointer to the OCI environment handle and server context handle are
          >supplied via elements zero and one of ociEnvInfo respectively.
          >Implementation s are free to ignore this parameter, and should do so
          >unless it is intended to use the Oracle connection of the calling
          >process.'
          >
          >void init(void *ociEnvInfo )
          >
          >What I have tried is the following;
          >
          >OCIEnv *envhp; /*OCI environment handle*/
          >OCISvcCtx *svchp; /*Server context handle*/
          >
          >void init(void *ociEnvInfo) {
          >
          envhp = (OCIEnv*)ociEnv Info[0];
          svchp = (OCISvcCtx*)oci EnvInfo[1];
          >
          >}
          >
          >This compiles fine :-) but I keep on getting an OCI_INVALID_HAN DLE
          >error which means I am probably not referencing the passed pointers
          >correctly.
          From your description I guess that init() expects an array of
          pointers to void.
          In your situation you want to pass an array of two pointers,
          the first being a pointer to OCIEnv, the second being a pointer to OCISvcCtx.
          If my assumption is wrong, please give more details, and ignore the rest
          of this post.

          The following works for me:

          /* defining your types here as dummies, just to make it compile */
          typedef struct OCIEnv_t OCIEnv;
          typedef struct OCISvcCtx_t OCISvcCtx;

          void init(void * vinfo)
          {
          void ** info = vinfo; /* treat passed vinfo as array of pointers to void */
          OCIEnv * envhp = info[0];
          OCISvcCtx * svchp = info[1];
          /* more code */
          }

          void call_init(void)
          {
          OCIEnv * the_oci;
          OCISvcCtx * the_svc;
          void * the_info[2];
          /* insert code that properly initializes the_oci and the_svc */
          the_info[0] = the_oci;
          the_info[1] = the_svc;
          init(the_info);
          }

          Comment

          • Nick Keighley

            #6
            Re: void pointers

            On 5 Aug, 07:16, bcpkh <vanheerden.br. ..@gmail.comwro te:
            Hope someone can help me, please note that at first this might look as
            if it is posted to the wrong group but if you ignore the specifics I
            think it is general pointer referencing issue.
            >
            I am building a plug-in library and is passed, according to the
            documentation the following;
            >
            'A pointer to the OCI environment handle and server context handle are
            supplied via elements zero and one of ociEnvInfo respectively.
            Implementations are free to ignore this parameter, and should do so
            unless it is intended to use the Oracle connection of the calling
            process.'
            >
            void init(void *ociEnvInfo )
            >
            What I have tried is the following;
            >
            OCIEnv                  *envhp; /*OCI environment handle*/
            OCISvcCtx               *svchp; /*Server context handle*/
            >
            void init(void *ociEnvInfo) {
            >
              envhp = (OCIEnv*)ociEnv Info[0];
              svchp = (OCISvcCtx*)oci EnvInfo[1];
            >
            }
            >
            This compiles fine :-) but I keep on getting an OCI_INVALID_HAN DLE
            error which means I am probably not referencing the passed pointers
            correctly.
            I really would try this on an Oracle group (they don't bite!).
            The clc people seem to be guessing wildly. The Oracle people
            may *really* know what's going on.


            --
            Nick Keighley

            Comment

            • Barry Schwarz

              #7
              Re: void pointers

              On Mon, 4 Aug 2008 23:32:14 -0700 (PDT), bcpkh
              <vanheerden.bra am@gmail.comwro te:
              >Hello Santosh
              Please don't top-post. Your response belongs immediately following
              the text it relates to.
              >
              >I gave your suggestion a try but my compiler returns the following
              >error;
              >
              >error #2852: expression must be a pointer to a
              complete object type
              This error tells you the compiler does not know the details of what an
              OCIEnv is. It is probably a structure of some kind but the
              declaration of the structure, including all its members, is not in
              scope.
              envhp = ((OCIEnv*)ociEn vInfo)[0];
              ^
              >
              >error #2852: expression must be a pointer to a
              complete object type
              Ditto for OCISvcCtx.
              svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
              ^
              >Any ideas?
              >
              >This is a syntax error.
              >>
              What I have tried is the following;
              >>
              OCIEnv                        *envhp; /*OCI environment handle*/
              OCISvcCtx             *svchp; /*Server context handle*/
              >>
              void init(void *ociEnvInfo) {
              You don't show how you call this function. Since the argument is
              apparently an array containing pointers of different types, the only
              way that makes sense is an array of void pointers. In this case, the
              correct parameter type would be void**. If this is not what your code
              does, then we need to see how you call the function.
              >>
                envhp = (OCIEnv*)ociEnv Info[0];
                svchp = (OCISvcCtx*)oci EnvInfo[1];
              >>
              >Try:
              >>
              >  envhp = ((OCIEnv*)ociEn vInfo)[0];
              >  svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
              >>
              --
              Remove del for email

              Comment

              • Barry Schwarz

                #8
                Re: void pointers

                On Mon, 4 Aug 2008 23:16:56 -0700 (PDT), bcpkh
                <vanheerden.bra am@gmail.comwro te:
                >Hello All
                >
                >Hope someone can help me, please note that at first this might look as
                >if it is posted to the wrong group but if you ignore the specifics I
                >think it is general pointer referencing issue.
                >
                >I am building a plug-in library and is passed, according to the
                >documentatio n the following;
                >
                >'A pointer to the OCI environment handle and server context handle are
                >supplied via elements zero and one of ociEnvInfo respectively.
                >Implementation s are free to ignore this parameter, and should do so
                >unless it is intended to use the Oracle connection of the calling
                >process.'
                >
                >void init(void *ociEnvInfo )
                >
                >What I have tried is the following;
                >
                >OCIEnv *envhp; /*OCI environment handle*/
                >OCISvcCtx *svchp; /*Server context handle*/
                >
                >void init(void *ociEnvInfo) {
                >
                envhp = (OCIEnv*)ociEnv Info[0];
                svchp = (OCISvcCtx*)oci EnvInfo[1];
                >
                >}
                >
                >This compiles fine :-) but I keep on getting an OCI_INVALID_HAN DLE
                This cannot compile fine. [] binds tighter than (cast). The
                expression is equivalent to (OCIEnv*)(ociEn fInfo[0]). You are
                attempting to dereference ociEnvInfo. Since that variable is a
                pointer to void, you cannot dereference it. Your compiler is required
                to issue a diagnostic. If it does not, up the warning level or
                upgrade to a competent implementation.
                >error which means I am probably not referencing the passed pointers
                >correctly.
                >
                >Can someone please point me in the right direction.
                >
                >Thank you,
                >
                >B
                >
                >PS: Running HP-UX on Itanium
                >
                --
                Remove del for email

                Comment

                • bcpkh

                  #9
                  Re: void pointers

                  >
                  You don't show how you call this function.  Since the argument is
                  apparently an array containing pointers of different types, the only
                  way that makes sense is an array of void pointers.  In this case, the
                  correct parameter type would be void**.  If this is not what your code
                  does, then we need to see how you call the function.
                  >
                  >
                  >
                    envhp = (OCIEnv*)ociEnv Info[0];
                    svchp = (OCISvcCtx*)oci EnvInfo[1];
                  >
                  Try:
                  >
                    envhp = ((OCIEnv*)ociEn vInfo)[0];
                    svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
                  >
                  --
                  Remove del for email
                  Unfortunately I don't call the function, the library that this
                  function sits in, an implementation of a published interface, gets
                  called by the process that loads the library, access to this
                  application is not possible.

                  Below a cut and paste from the supplied header;

                  void init(GER_t *pStatus,
                  void *ociEnvInfo[],
                  OMinfo_t *pInfo);

                  init gets called by the 'parent' process once when it starts and I
                  need to use the passed DB info to interact with the database.

                  Comment

                  • bcpkh

                    #10
                    Re: void pointers

                    On Aug 5, 9:12 am, blargg <blargg....@gis hpuppy.comwrote :
                    In article <g78rnd$47...@r egistered.motza rella.org>,
                    >
                    >
                    >
                     santosh <santosh....@gm ail.comwrote:
                    bcpkh wrote:
                    [...]
                    'A pointer to the OCI environment handle and server context handle are
                    supplied via elements zero and one of ociEnvInfo respectively.
                    Implementations are free to ignore this parameter, and should do so
                    unless it is intended to use the Oracle connection of the calling
                    process.'
                    [...]
                    OCIEnv                *envhp; /*OCI environment handle*/
                    OCISvcCtx             *svchp; /*Server context handle*/
                    >
                    void init(void *ociEnvInfo) {
                    >
                      envhp = (OCIEnv*)ociEnv Info[0];
                      svchp = (OCISvcCtx*)oci EnvInfo[1];
                    >
                    Try:
                    >
                      envhp = ((OCIEnv*)ociEn vInfo)[0];
                      svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
                    >
                    (which also gives an error)
                    >
                    Sounds like init is supposed to take a void**:
                    >
                    void init(void **ociEnvInfo) {
                    >
                      envhp = ociEnvInfo[0];
                      svchp = ociEnvInfo[1];
                    >
                    }
                    >
                    If for some reason it's misdeclared to take a void* in the interface,
                    then make a local variable that's a cast of the parameter:
                    >
                    void init(void *param) {
                    >
                      void **ociEnvInfo = param;
                      envhp = ociEnvInfo[0];
                      svchp = ociEnvInfo[1];
                    >
                    }
                    >
                    Since this is C, there's no need to do any pointer casts as all the
                    source operands are void*.
                    Have tried your suggestion but, compile fine but still getting the
                    OCI_INVALID_HAN DLE error. Thanks.

                    Comment

                    • santosh

                      #11
                      Re: void pointers

                      bcpkh wrote:
                      >>
                      >You don't show how you call this function.  Since the argument is
                      >apparently an array containing pointers of different types, the only
                      >way that makes sense is an array of void pointers.  In this case, the
                      >correct parameter type would be void**.  If this is not what your
                      >code does, then we need to see how you call the function.
                      >>
                      >>
                      >>
                      envhp = (OCIEnv*)ociEnv Info[0];
                      svchp = (OCISvcCtx*)oci EnvInfo[1];
                      >>
                      >Try:
                      >>
                      >envhp = ((OCIEnv*)ociEn vInfo)[0];
                      >svchp = ((OCISvcCtx*)oc iEnvInfo)[1];
                      >>
                      >--
                      >Remove del for email
                      >
                      Unfortunately I don't call the function, the library that this
                      function sits in, an implementation of a published interface, gets
                      called by the process that loads the library, access to this
                      application is not possible.
                      >
                      Below a cut and paste from the supplied header;
                      >
                      void init(GER_t *pStatus,
                      void *ociEnvInfo[],
                      OMinfo_t *pInfo);
                      >
                      init gets called by the 'parent' process once when it starts and I
                      need to use the passed DB info to interact with the database.
                      You can do:

                      evnc_something_ or_the_other_pt r = ociEnvInfo[0];

                      and similarly for the other one.

                      Comment

                      • Ben Bacarisse

                        #12
                        Re: void pointers

                        bcpkh <vanheerden.bra am@gmail.comwri tes:
                        Below a cut and paste from the supplied header;
                        >
                        void init(GER_t *pStatus,
                        void *ociEnvInfo[],
                        OMinfo_t *pInfo);
                        >
                        init gets called by the 'parent' process once when it starts and I
                        need to use the passed DB info to interact with the database.
                        This suggests that your prototype for init is wrong. It should look
                        the above. You were accessing the first parameter, whereas now it
                        looks like thge seond is the one you want, and rather than being a
                        void * it points to an array of void pointers. You function must look
                        like the above if that is what the called expects.

                        Note also that your previous code should have had errors saying, in
                        effect, that the definition of init does not match its prototype. If
                        you did not, then either you did not include this header (and it is
                        probably a good thing to do that) or you have the warning level set
                        rather low on your compiler.

                        --
                        Ben.

                        Comment

                        • CBFalconer

                          #13
                          Re: void pointers

                          bcpkh wrote:
                          >
                          Hope someone can help me, please note that at first this might
                          look as if it is posted to the wrong group but if you ignore the
                          specifics I think it is general pointer referencing issue.
                          >
                          I am building a plug-in library and is passed, according to the
                          documentation the following;
                          >
                          'A pointer to the OCI environment handle and server context handle
                          are supplied via elements zero and one of ociEnvInfo respectively.
                          Implementations are free to ignore this parameter, and should do so
                          unless it is intended to use the Oracle connection of the calling
                          process.'
                          >
                          void init(void *ociEnvInfo )
                          You are definitely on the wrong group. We deal with standard C,
                          and things programmable in standard C. You have omitted the source
                          of the "OCI environment", without which there is no answer on this
                          newsgroup. I believe that has something to do with Oracle, so you
                          should find a newsgroup that deals with Oracle.

                          --
                          [mail]: Chuck F (cbfalconer at maineline dot net)
                          [page]: <http://cbfalconer.home .att.net>
                          Try the download section.


                          Comment

                          • Ben Bacarisse

                            #14
                            Re: void pointers

                            CBFalconer <cbfalconer@yah oo.comwrites:
                            >Hope someone can help me, please note that at first this might
                            >look as if it is posted to the wrong group but if you ignore the
                            >specifics I think it is general pointer referencing issue.
                            >>
                            >I am building a plug-in library and is passed, according to the
                            >documentatio n the following;
                            <snip>
                            You are definitely on the wrong group. We deal with standard C,
                            and things programmable in standard C.
                            That does not seem to be the case. For example, you discussed your
                            allocator here and I doubt that is programmable in standard C.
                            You have omitted the source
                            of the "OCI environment", without which there is no answer on this
                            newsgroup.
                            Enough has (now) been posted to suggest an answer that is topical --
                            the OP's function does not match the prototype used to call it.
                            I believe that has something to do with Oracle, so you
                            should find a newsgroup that deals with Oracle.
                            Yes, I agree. The OP will probably get better answers in an Oracle
                            group, provided there is one populated with good C programmers.

                            --
                            Ben.

                            Comment

                            • CBFalconer

                              #15
                              Re: void pointers

                              Ben Bacarisse wrote:
                              CBFalconer <cbfalconer@yah oo.comwrites:
                              >
                              .... snip ...
                              >
                              >You are definitely on the wrong group. We deal with standard C,
                              >and things programmable in standard C.
                              >
                              That does not seem to be the case. For example, you discussed your
                              allocator here and I doubt that is programmable in standard C.
                              Huh? What is this 'allocator' jazz? One of us is confused.

                              --
                              [mail]: Chuck F (cbfalconer at maineline dot net)
                              [page]: <http://cbfalconer.home .att.net>
                              Try the download section.


                              Comment

                              Working...