"dereferencing pointer to incomplete type"

"dereferencing pointer to incomplete type"

Post by Rod Bric » Wed, 26 Aug 1998 04:00:00



Can someone explain this message to me and how I might fix it.  I'm
running gcc 2.7.2.1 under Linux.  If you could respond via email, I
would be most appreciative.  Thanks.

Rod

 
 
 

"dereferencing pointer to incomplete type"

Post by cra.. » Thu, 27 Aug 1998 04:00:00



Quote:> Can someone explain this message to me and how I might fix it.  I'm

        ("dereferencing pointer to incomplete type")

You are attempting to dereference a pointer to a data type that is not
described completely in the current translation unit.

For example,

        extern struct foo;
        extern void baz( struct foo*);
        void bar( struct foo* arg) { baz( arg); }  

is legal C (and C++), whereas

        extern struct foo;
        extern void baz( int);
        void bar( struct foo* arg) { baz( arg->number); }  

is not, because the second case requires that the compiler know
the description of a "struct foo".  Without the structure definition,
the compiler knows not that a struct foo has a member "number", nor
of what type this hypothetical member might be.

In other words, it is OK to declare pointers to types that have been
declared but not defined, but it is not OK to dereference thost pointers.

Regards,

Craig

 
 
 

1. Solving "dereferencing pointer to incomplete type" error

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)

2. Noisy Keyboard and Mouse(Can't Install)

3. Type "(", ")" and "{", "}" in X...

4. Question from lamer - installation problem

5. : dereferencing pointer to incomplete type

6. chat and pppd problem

7. 2.5.5 -- filesystems.c:30: In function `sys_nfsservctl': dereferencing pointer to incomplete type

8. Dereferencing pointer to incomplete type

9. 2.5.18 -- build failure -- suspend.c:1052: dereferencing pointer to incomplete type

10. dereferencing pointer to incomplete type?

11. GETSERVBYNAME()????????????????????"""""""""""""