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
Printable View
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
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).
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
Header file( a0TargInp.hCode:#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");
}
) 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();