include file syntax errors?

Richard Todd rmtodd at servalan.uucp
Thu Oct 18 09:52:19 AEST 1990


cwilson at NISC.SRI.COM (Chan Wilson [Animal]) writes:
>I'm trying to port some fairly tame programs we've developed here, and 
>keep running into a include file syntax errors!  There's more than
>one; /usr/include/utmp.h springs to mind, but I seen to recall file.h
>having problems also.  

  Nope, this isn't a syntax error in the include file, it's an error in your
program.  Let's take a look at what happens when I try to compile the sample
program you posted:

	21 servalan /tmp[6:43pm] % cat >foo.c
	#include <utmp.h>
	main() {}
	22 servalan /tmp[6:43pm] % gcc foo.c
	In file included from foo.c:1:
	/usr/include/utmp.h:40: parse error before `time_t'
Looking at utmp.h, one notes that the file uses a typedef'd type, time_t,
but does not have the definition for time_t.  The definition for that, along
with a lot of other special types, is found in /usr/include/sys/types.h.
Thus one should #include <sys/types.h> before #include-ing <utmp.h>, viz.:

	26 servalan /tmp[6:49pm] % cat >foo.c
	#include <sys/types.h>
	#include <utmp.h>
	main() {}
	27 servalan /tmp[6:50pm] % gcc foo.c
	28 servalan /tmp[6:50pm] %

Look, Ma, no errors.  
--
Richard Todd	rmtodd at uokmax.ecn.uoknor.edu  rmtodd at chinet.chi.il.us
	rmtodd at servalan.uucp
Motorola Skates On Intel's Head!



More information about the Comp.unix.aux mailing list