Subject: Re: Hello world won't compile, what did I do wrong?
To: Steven Grunza <steven.grunza@dgms.com>
From: David Maxwell <david@fundy.ca>
List: port-sparc
Date: 06/16/1999 16:21:34
On Wed, Jun 16, 1999 at 03:03:15PM -0400, Steven Grunza wrote:
> > > Why doesn't this build?  Can anyone help with this?  It works on 
> a
> > > NetBSD-1.4 fresh install but not on a NetBSD-1.4 upgrade.
> > >
> grunza@hw-ss1%(285) cat hello.c
> #include <sys/types.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <stdlib.h>
> 
> int main( void )
> {
>    printf( "Hello world\n" );
>    return( EXIT_SUCCESS );
> }
> /usr/include/unistd.h:253: syntax error before `ualarm'
> /usr/include/unistd.h:253: warning: parameter names (without types) 
> in function declaration
> /usr/include/unistd.h:253: warning: data definition has no type or 
> storage class
> /usr/include/unistd.h:254: warning: parameter names (without types) 
> in function declaration
> grunza@hw-ss1%(287)
> 
> Including <sys/ansi.h> fixed the problem but why is it necessary? 
>  What part of the building of a normal C program is supposed to add 
> <sys/ansi.h>?

I don't have a 1.4 upgrade to test on. The error is the type
useconds_t being undefined, in unistd.h

I think these are the relevant references:

/usr/include/sys/types.h:149:#ifdef     _BSD_USECONDS_T_
/usr/include/sys/types.h:150:typedef    _BSD_USECONDS_T_        useconds_t;
/usr/include/sys/types.h:151:#undef     _BSD_USECONDS_T_
/usr/include/i386/ansi.h:59:#define     _BSD_USECONDS_T_        unsigned int    /* useconds_t */

(from types.h)
#ifdef  _BSD_SUSECONDS_T_
typedef _BSD_SUSECONDS_T_       suseconds_t;
#undef  _BSD_SUSECONDS_T_
#endif

(from i386/ansi.h)
#define _BSD_USECONDS_T_        unsigned int    /* useconds_t */

sys/types.h includes machine/ansi.h, so this should be done already without
you having to manually include it. Could you check your /usr/include/machine
subdir for sanity? I seem to remember hearing something about /include/machine,
but I don't think it applied to i386.
 
-- 
David Maxwell, david@vex.net|david@maxwell.net --> Mastery of UNIX, like
mastery of language, offers real freedom. The price of freedom is always dear,
but there's no substitute. Personally, I'd rather pay for my freedom than live
in a bitmapped, pop-up-happy dungeon like NT. - Thomas Scoville