: dereferencing pointer to incomplete type

: dereferencing pointer to incomplete type

Post by Young4er » Mon, 09 Apr 2001 01:06:32



Hi,

I am trying to make a sense out of the following partial code:

        #include <dirent.h>
        dirent *dp;
        if (!strcmp(dp->d_name, ".")) continue;
                .
                :

And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
following error message:

        dereferencing pointer to incomplete type

I am just trying to learn C and got stuck with such an error.  If you can
shed some lights in this matter, I certainly will appreicate it.

TIA.

 
 
 

: dereferencing pointer to incomplete type

Post by Joseph A. Knapk » Mon, 09 Apr 2001 07:07:31



> Hi,

> I am trying to make a sense out of the following partial code:

>         #include <dirent.h>
>         dirent *dp;
>         if (!strcmp(dp->d_name, ".")) continue;
>                 .
>                 :

> And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
> following error message:

>         dereferencing pointer to incomplete type

This error means that at the point "dp->d_name" is compiled, the
compiler has not seen the definition of "dirent" and all of its
members. We will probably need to see more of your code in order to
help you any further. I cannot reproduce this error on my machine
(gcc 2.95.2, glibc 2.1, i386).

I don't believe glibc provides a typedef of dirent; you might try
declaring dp as "struct dirent* dp;".

Good luck,

-- Joe

Quote:> I am just trying to learn C and got stuck with such an error.  If you can
> shed some lights in this matter, I certainly will appreicate it.

> TIA.

-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
 have happened to anyone." -- Pratchett
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *

 
 
 

: dereferencing pointer to incomplete type

Post by Young4er » Mon, 09 Apr 2001 07:55:23


Thank you very much for your quick response and explanation.  It turned out
that the "dirent" structure was declared within the #if defined(__i386__)
and my Makefile did not include the "-D__i386__" switch.


>> Hi,

>> I am trying to make a sense out of the following partial code:

>>         #include <dirent.h>
>>         dirent *dp;
>>         if (!strcmp(dp->d_name, ".")) continue;
>>                 .
>>                 :

>> And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
>> following error message:

>>         dereferencing pointer to incomplete type

> This error means that at the point "dp->d_name" is compiled, the
> compiler has not seen the definition of "dirent" and all of its
> members. We will probably need to see more of your code in order to
> help you any further. I cannot reproduce this error on my machine
> (gcc 2.95.2, glibc 2.1, i386).

> I don't believe glibc provides a typedef of dirent; you might try
> declaring dp as "struct dirent* dp;".

> Good luck,

> -- Joe

>> I am just trying to learn C and got stuck with such an error.  If you can
>> shed some lights in this matter, I certainly will appreicate it.

>> TIA.

> -- Joe Knapka
> "It was just a maddened crocodile hidden in a flower bed. It could
>  have happened to anyone." -- Pratchett
> // Linux MM Documentation in progress:
> // http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
> * Evolution is an "unproven theory" in the same sense that gravity is. *

 
 
 

: dereferencing pointer to incomplete type

Post by Floyd Davidso » Mon, 09 Apr 2001 09:30:08



>Thank you very much for your quick response and explanation.  It turned out
>that the "dirent" structure was declared within the #if defined(__i386__)
>and my Makefile did not include the "-D__i386__" switch.

That should be a predefined macro, assuming it is appropriate
for your platform of course.  You can determine which macros are
predefined by using the -dM option to gcc on a basically empty
file, like this:

   echo 'main(){}' > foo.c
   gcc -E -dM foo.c

If you have an Intel based system, __i386__ should be defined.
Otherwise it shouldn't.

My headers are different than yours (I'm using a 2.2.13
kernel and headers), and the definition of struct dirent
is not wrapped in a conditional (it is in
/usr/include/linux/dirent.h) plus there is no typedef for
"dirent", hence "dirent *dp" is not defined.

The import of that is that regardless of how it is
defined/typedef'd on your system, that is not going to be a
portable usage, and  "struct dirent *dp" will be portable.



>>> Hi,

>>> I am trying to make a sense out of the following partial code:

>>>         #include <dirent.h>
>>>         dirent *dp;
>>>         if (!strcmp(dp->d_name, ".")) continue;
>>>                 .
>>>                 :

>>> And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
>>> following error message:

>>>         dereferencing pointer to incomplete type

>> This error means that at the point "dp->d_name" is compiled, the
>> compiler has not seen the definition of "dirent" and all of its
>> members. We will probably need to see more of your code in order to
>> help you any further. I cannot reproduce this error on my machine
>> (gcc 2.95.2, glibc 2.1, i386).

>> I don't believe glibc provides a typedef of dirent; you might try
>> declaring dp as "struct dirent* dp;".

>> Good luck,

>> -- Joe

>>> I am just trying to learn C and got stuck with such an error.  If you can
>>> shed some lights in this matter, I certainly will appreicate it.

--
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>

 
 
 

: dereferencing pointer to incomplete type

Post by Young4er » Mon, 09 Apr 2001 10:51:49


I just wanted to let you know that I have appreciated your pointers as well
as your explanations and thank you very much.


>>Thank you very much for your quick response and explanation.  It turned
>>out that the "dirent" structure was declared within the #if
>>defined(__i386__) and my Makefile did not include the "-D__i386__" switch.

> That should be a predefined macro, assuming it is appropriate
> for your platform of course.  You can determine which macros are
> predefined by using the -dM option to gcc on a basically empty
> file, like this:

>    echo 'main(){}' > foo.c
>    gcc -E -dM foo.c

> If you have an Intel based system, __i386__ should be defined.
> Otherwise it shouldn't.

> My headers are different than yours (I'm using a 2.2.13
> kernel and headers), and the definition of struct dirent
> is not wrapped in a conditional (it is in
> /usr/include/linux/dirent.h) plus there is no typedef for
> "dirent", hence "dirent *dp" is not defined.

> The import of that is that regardless of how it is
> defined/typedef'd on your system, that is not going to be a
> portable usage, and  "struct dirent *dp" will be portable.



>>>> Hi,

>>>> I am trying to make a sense out of the following partial code:

>>>>         #include <dirent.h>
>>>>         dirent *dp;
>>>>         if (!strcmp(dp->d_name, ".")) continue;
>>>>                 .
>>>>                 :

>>>> And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
>>>> following error message:

>>>>         dereferencing pointer to incomplete type

>>> This error means that at the point "dp->d_name" is compiled, the
>>> compiler has not seen the definition of "dirent" and all of its
>>> members. We will probably need to see more of your code in order to
>>> help you any further. I cannot reproduce this error on my machine
>>> (gcc 2.95.2, glibc 2.1, i386).

>>> I don't believe glibc provides a typedef of dirent; you might try
>>> declaring dp as "struct dirent* dp;".

>>> Good luck,

>>> -- Joe

>>>> I am just trying to learn C and got stuck with such an error.  If you
>>>> can shed some lights in this matter, I certainly will appreicate it.

 
 
 

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

This has been reported by someone else, but the .config
information was not included in the report.  Hopefully,
this will help.

Here you go:

CONFIG_QUOTA=y
CONFIG_AUTOFS4_FS=y
CONFIG_EXT3_FS=y
CONFIG_JBD=y
CONFIG_JBD_DEBUG=y
CONFIG_FAT_FS=m
CONFIG_VFAT_FS=m
CONFIG_RAMFS=y
CONFIG_ISO9660_FS=m
CONFIG_JOLIET=y
CONFIG_ZISOFS=y
CONFIG_PROC_FS=y
CONFIG_DEVPTS_FS=y
CONFIG_EXT2_FS=y

gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes
-Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common
-pipe -mpreferred-stack-boundary=2 -march=athlon  
-DKBUILD_BASENAME=filesystems  -DEXPORT_SYMTAB -c filesystems.c
filesystems.c: In function `sys_nfsservctl':
filesystems.c:30: dereferencing pointer to incomplete type
filesystems.c:30: dereferencing pointer to incomplete type
filesystems.c:30: warning: value computed is not used
filesystems.c:32: dereferencing pointer to incomplete type
filesystems.c:33: dereferencing pointer to incomplete type
filesystems.c:33: dereferencing pointer to incomplete type
filesystems.c:33: warning: value computed is not used
make[2]: *** [filesystems.o] Error 1
make[2]: Leaving directory `/usr/src/linux/fs'

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. how to setenv by tcsh

3. Dereferencing pointer to incomplete type

4. Linux & smp

5. help with backup

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

7. Proxy + ipfw slow??

8. dereferencing pointer to incomplete type?

9. Solving "dereferencing pointer to incomplete type" error

10. "dereferencing pointer to incomplete type"

11. wu-ftpd.2.4 on linux compile error. ( dereferencing pointer to incomplete type)

12. Please help!! structure datatype scope (dereferencing pointer to incomplete type)