[ILUG] C compilation error

Ronan Waide waider at waider.ie
Sat Jan 26 21:55:34 GMT 2002


On January 26, niall at linux.ie said:
> OK - this tiny program
> 
> ---------------------
> #include <sys/time.h>
> 
> main() {
>   struct tm *tp;
> 
>   tp = localtime();
>   tp->tm_isdst;
> }
> ---------------------
> 
> generates the following wrning and error
> 
> timeq.c: In function main':
> timeq.c:8: warning: assignment makes pointer from integer without a cast
> timeq.c:9: dereferencing pointer to incomplete type
> 
> when compiled on a SuSE 7.3 box with gcc 2.95.3 and glibc 2.2.4
> 
> It compiles with no warning or error on a SuSE 6.4 box with gcc 2.95.2 and
> libc 2.1.3 (yes, libc, not glibc - seems like a strange libc version number
> to me)
> 
> While I'm no C whizkid, nor am I C illiterate and I just don't understand
> these errors. I have 

incomplete type means that the struct has been declared but not
defined. In your code snippet, you're declaring tp to be a pointer to
a struct tm, but it looks like the definition of the tm struct has
been removed from sys/time.h. You may find it's been relocated to
/usr/include/time.h; poking around in /usr should turn it up.

Cheers,
Waider.
-- 
waider at waider.ie / Yes, it /is/ very personal of me.

"for god's sake, give me some credit.  i may be an egocentric jerk, but i'm
 not a COMPLETE asshole." - Meredith




More information about the ILUG mailing list