Solving "dereferencing pointer to incomplete type" error

Solving "dereferencing pointer to incomplete type" error

Post by Paul Colclou » Fri, 14 Aug 1998 04:00:00



Anyone tell me what's wrong with the following code? GCC complains I'm
dereferencing an incomplete pointer in the "if" statements, but I'm
not sure why.

ptrptr is a hack - It's currently "unsigned char *ptrptr".
xxbuff is "unsigned char *xxbuff" malloced.
SCSI_HDR is constant (#define)
scsi_modesel_header is struct containing unsigned char's
cd_mode_page_2a is struct containing unsigned char's

               ptrptr=(xxbuff+(SCSI_HDR+sizeof(struct
scsi_modesel_header)));
               page2a = (struct cd_mode_page_2a *)ptrptr;
               if (page2a->cd_r_write) strcat (str," R:Y");
               if (page2a->cd_rw_write) strcat (str," RW:Y");

--
Remove the vegetable in my email address to reply sucessfully.
http://squidge.carrot.nu (remove the vegetable)

 
 
 

Solving "dereferencing pointer to incomplete type" error

Post by Fletcher Gle » Fri, 14 Aug 1998 04:00:00


Instead of doing all of this strange pointer arithmetic, why don't you
put the data into a union of xxbuff and struct cd_mode_page_2a?

--
                Fletcher Glenn


>Anyone tell me what's wrong with the following code? GCC complains I'm
>dereferencing an incomplete pointer in the "if" statements, but I'm
>not sure why.

>ptrptr is a hack - It's currently "unsigned char *ptrptr".
>xxbuff is "unsigned char *xxbuff" malloced.
>SCSI_HDR is constant (#define)
>scsi_modesel_header is struct containing unsigned char's
>cd_mode_page_2a is struct containing unsigned char's

>           ptrptr=(xxbuff+(SCSI_HDR+sizeof(struct
>scsi_modesel_header)));
>           page2a = (struct cd_mode_page_2a *)ptrptr;
>           if (page2a->cd_r_write) strcat (str," R:Y");
>           if (page2a->cd_rw_write) strcat (str," RW:Y");

>--
>Remove the vegetable in my email address to reply sucessfully.
>http://squidge.carrot.nu (remove the vegetable)


 
 
 

Solving "dereferencing pointer to incomplete type" error

Post by Horst Kraem » Sat, 15 Aug 1998 04:00:00




>Anyone tell me what's wrong with the following code? GCC complains I'm
>dereferencing an incomplete pointer in the "if" statements, but I'm
>not sure why.

>ptrptr is a hack - It's currently "unsigned char *ptrptr".
>xxbuff is "unsigned char *xxbuff" malloced.
>SCSI_HDR is constant (#define)
>scsi_modesel_header is struct containing unsigned char's
>cd_mode_page_2a is struct containing unsigned char's

>           ptrptr=(xxbuff+(SCSI_HDR+sizeof(struct
>scsi_modesel_header)));
>           page2a = (struct cd_mode_page_2a *)ptrptr;
>           if (page2a->cd_r_write) strcat (str," R:Y");
>           if (page2a->cd_rw_write) strcat (str," RW:Y");

This error has to do _only_ with the declaration of

        struct cd_mode_page_2a

I'm assuming that page2a is declared as

        struct cd_mode_page_2a *page2a;

The compiler is telling you that the declaration of this struct is
_incomplete_, i.e. that it cannot determine the size of the struct for
some reason.

You should post the exact declaration of this struct.

Regards
Horst