gcc bug?

Bill Mills-Curran bcurran@clariion.com
Wed Oct 20 06:09:00 GMT 1999


I think I have found a gcc-related bug, but I'm not sure to whom this
problem belongs, so I'll start here.  The problem has to do with the
definition of type pid_t.  According to the man page for fork on
the RedHat 6.0 distribution:

****************
NAME
       fork, vfork - create a child process

SYNOPSIS
       #include <unistd.h>

       pid_t fork(void);
       pid_t vfork(void);
****************

Using this information, I wrote the following simple source test:

****************
#include <unistd.h>

int bozo(void) 
{
	pid_t ret;
	ret = fork();
}
****************

Compiling:

****************
bcurran_pent584> gcc -c bozo.c
bozo.c: In function `bozo':
bozo.c:5: `pid_t' undeclared (first use in this function)
bozo.c:5: (Each undeclared identifier is reported only once
bozo.c:5: for each function it appears in.)
bozo.c:5: parse error before `ret'
bozo.c:6: `ret' undeclared (first use in this function)
****************

My POSIX book (POSIX Programmer's Guide by Donald Lewine) says that
the fork function requires both sys/types.h and unistd.h.  It also
says that pid_t is defined in sys/types.h.  If I change my test code:

****************
#include <sys/types.h>
#include <unistd.h>

int bozo(void) 
{
	pid_t ret;
	ret = fork();
}
****************

Everything works fine.

System info:

bcurran_pent584> gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

bcurran_pent584> cat /proc/version
Linux version 2.2.5-15 (root@porky.devel.redhat.com) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)) #1 Mon Apr 19 23:00:46 EDT 1999


Thanks,
Bill

-- 
Bill Mills-Curran                         (bcurran@clariion.com)
Clariion                                  Tel: 508 480-7642
Coslin Drive, MS C33                      Fax: 508 480-7913
Southboro, MA 01772



More information about the Gcc-bugs mailing list