dereferencing pointer to incomplete type

This is a discussion on dereferencing pointer to incomplete type within the C Programming forums, part of the General Programming Boards category; Hi Can anyone tell me why following error gets generated? "dereferencing pointer to incomplete type" What does it mean and ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    50

    dereferencing pointer to incomplete type

    Hi

    Can anyone tell me why following error gets generated?

    "dereferencing pointer to incomplete type"

    What does it mean and what is its exact reason?

    Thanks in advance
    Sas

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,739
    It sounds like only the declaration of the type is available at that point; the type definition must be available to, otherwise you cannot access an object of that type (though you can have a pointer to it).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    Thanks for you reply..

    What i am trying to acomplish is i am fetching some records from database and putting that records in dynamically generated pointer array and returning the pointer to main function. In the main function i am trying to get the value oif the structure member by dereferencing.While compiling the code i am getting the error.

    Can you please help me what went wrong in the code..

    The structure is declared in a0TargInp.h header file
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <sqlda.h>
    #include <sqlcpr.h>
    #include <stdlib.h>
    #include "a0TargInp.h"
    
    EXEC SQL INCLUDE SQLCA.H;
    /*
    struct a0_targ_inp
            {
            char equip_cd[10];
            float min_chg;
            float max_chg;
            float ao_incv;
            char apply_cnstrn_flag[4];
            char hard_cnstrn_flag[4];
            int bank_start;
            int bank_end;
            };
    
    struct a0_targ_inp * getA0TargInp();
    */
    int main()
    {
    
    
    
            struct ao_targ_inp * a0,a0_data=NULL;
    
            int cnt,i;
    
            a0=(struct ao_targ_inp *)calloc(1,sizeof(a0_data));
    
    /*
            struct a0_targ_inp * getA0TargInp();
    */
            dbConnect();
    
            cnt=getRecordCount();
            a0=getA0TargInp();
    
    
            for(i=0;i<cnt;i++)
            {
    
                    printf("\n %s  %f  %f  %f  %s  %s  %d  %d\n",a0->equip_cd, a0->min_chg,a0->max_chg,a0->ao_incv,a0->apply_cnstrn_flag,a0->hard_cnstrn_flag,a0->bank_start,a0->bank_end);
    
                    a0=a0+1;
            }
    
    
    
            free(a0);
            EXEC SQL COMMIT WORK RELEASE;
            return 0;
    
    
    
            errexit:
    
            printf("\nConnection failed\n");
    
            return 0;
    
            sqlerr:
            printf("\n SQL error occured during execution of sql\n");
    
    
    }
    
    struct a0_targ_inp * getA0TargInp()
    {
    
    
    
    
            int i=0;
    
            struct a0_targ_inp * a0,*tmp,a0_data;
    
    
           EXEC SQL DECLARE get_a0_targ_inp CURSOR FOR
                    SELECT b.equip_cd,
                          a.minm_a0_chg_allw,
                          a.max_a0_chg_allw,
                          a.a0_inctv,
                          a.apply_cnstrn_flag,
                          a.hard_cnstrn_flag,
                          a.bank_start,
                          a.bank_end
                    FROM a0_targ_inp a,a0_targ_inp_equip b
                    WHERE a.A0_TARG_INP_ID=b.a0_targ_inp_id
                    AND a.da_mon='Y'
                    AND a.da_tue='Y'
                    AND a.da_wed='Y'
                    AND a.da_thur='Y'
                    AND a.da_fri='Y'
                    AND a.da_sat='Y'
                    AND a.da_sun='Y'
                    AND a.eff_dt<='12-OCT-10'
                    AND a.discont_dt>='12-OCT-10'
                    AND b.EQUIP_GRP_FLAG='N'
                    OR b.equip_grp_flag='Y';
    
            EXEC SQL WHENEVER sqlerror DO  printSQLError();
    
    
            a0=(struct ao_targ_inp *)calloc(cnt,sizeof(a0_data));
            tmp=a0;
    
    
            EXEC SQL OPEN get_a0_targ_inp;
    
    
            EXEC SQL WHENEVER NOT FOUND DO break;
    
            for(;;)
            {
                    EXEC SQL FETCH get_a0_targ_inp INTO :a0;
                    a0=a0+1;
            }
    
    
            EXEC SQL CLOSE get_a0_targ_inp;
              return tmp;
    
    }
    
    void dbConnect()
    {
    
            EXEC SQL BEGIN DECLARE SECTION;
    
            char oracleid[50]="sdouser01/sdoual1@SDO_DEV_LINUX";
    
            EXEC SQL END DECLARE SECTION;
    
            EXEC SQL WHENEVER sqlerror DO printError();
            EXEC SQL CONNECT :oracleid;
    
    
    }
    
    
    
    int getRecordCount()
    {
    
            EXEC SQL BEGIN DECLARE SECTION;
             int cnt=0;
            EXEC SQL END DECLARE SECTION;
    
    
    
            EXEC SQL WHENEVER sqlerror DO  printSQLError();
    
              EXEC SQL SELECT COUNT(*) INTO :cnt FROM ( SELECT b.equip_cd,
                  a.minm_a0_chg_allw,
                  a.max_a0_chg_allw,
                  a.a0_inctv,
                  a.apply_cnstrn_flag,
                  a.hard_cnstrn_flag,
                  a.bank_start,
                  a.bank_end
            FROM a0_targ_inp a,a0_targ_inp_equip b
            WHERE a.A0_TARG_INP_ID=b.a0_targ_inp_id
            AND a.da_mon='Y'
            AND a.da_tue='Y'
            AND a.da_wed='Y'
            AND a.da_thur='Y'
            AND a.da_fri='Y'
            AND a.da_sat='Y'
            AND a.da_sun='Y'
            AND a.eff_dt<='12-OCT-10'
            AND a.discont_dt>='12-OCT-10'
            AND b.EQUIP_GRP_FLAG='N'
            OR b.equip_grp_flag='Y');
    
            return cnt;
    }
    
    void printError()
    {
    
            printf("\n Unable to connect to database\n");
    
    }
    
    void printSQLError()
    {
    
            printf("\n Error ocurred during execution of SQL\n");
    
    }
    Header file( a0TargInp.h
    ) is as below

    Code:
    struct a0_targ_inp
            {
            char equip_cd[10];
            float min_chg;
            float max_chg;
            float ao_incv;
            char apply_cnstrn_flag[4];
            char hard_cnstrn_flag[4];
            int bank_start;
            int bank_end;
            };
    
    struct a0_targ_inp * getA0TargInp();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: dereferencing pointer to incomplete type
    By kiros88 in forum C Programming
    Replies: 4
    Last Post: 09-16-2009, 02:43 PM
  2. error: dereferencing pointer to incomplete type
    By surlyTomato in forum C Programming
    Replies: 10
    Last Post: 08-22-2009, 08:04 AM
  3. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  4. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  5. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21