On Sun, 25 May 2008, deoxy wrote:

> Hello.
> 
> I dont know if this a cuestion for this list, but I think is it a valid 
> cuestion...
> I reading a book recomended in http://www.openbsd.org/books.html The book is 
> "Advanced programmig in the unix environment".
> In this book I read Figure 3.1 but this not compile. the error is:
> 
> $cc F3_10.c
> /tmp//ccnsuA79.o(.text+027): In function 'main':
> :undefined reference to 'err_quit'
> /tmp//ccnsuA79.o(.text+0x74): In fuction 'main':
> :undefined reference to 'err_sys'
> /tmp//ccnsuA79.o(.txt+0xdf): In functiion 'main':
> :undefined reference to 'err_dump'
> collect2: ld returned 1 exit status
> 
> The source is:
> 
> 
> #include "apue.h"
> #include <fcntl.h>
> 
> int
> main(int argc, char *argv[])
> {
>       int val;
>       if (argc != 2)
>         err_quit("usage: a.out <descriptor#>");
>       if ((val = fcntl(atoi(argv[1]), F_GETFL, 0)) < 0)
>         err_sys("fcntl error for fd %d", atoi(argv[1]));

You might be happier using the err(3) stuff from the standard
library.

See man err

I would replace err_quit(stuff) with  errx(1, stuff)
                err_sys(stuff)  with  warn(stuff)

and so on, using err or errx to force the program to end
and dump core, or warn or warnx to keep executing.

Some (old) unix versions may not have err, errx, warn, warnx.

Look in the back of the book and verify that the err/warn stuff
is doing what you expect.

Dave

Reply via email to