>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>