advanced programming unix environment

Brother Seamus brother_seamus at btinternet.com
Mon Apr 14 17:15:40 UTC 2008


I am trying to build the neccesary files for the stevens/rago APUE.2e book on FreeBSD 7.0

as instructed i get the source from here: http://www.apuebook.com/src.tar.gz

unzip & untar to:

/home/seamus/apue.2e

cd /home/seamus/apue.2e

amend "Make.defines.freebsd" as instructed so:
"WKDIR=/home/seamus/apue.2e"

and then run "make" from this directory.

I get the following error:
+++++++++++++++++++++++++++++++++++++++++
pracct.c  ../lib/libapue.a 
pracct.c: In function 'main':
pracct.c:31: error: storage size of 'acdata' isn't known
pracct.c:31: warning: unused variable 'acdata'
*** Error code 1

Stop in /usr/home/seamus/apue.2e/proc.
*** Error code 1

Stop in /usr/home/seamus/apue.2e.
*** Error code 1

Stop in /usr/home/seamus/apue.2e.
+++++++++++++++++++++++++++++++++++++++++

I would appreciate any help.

+++++++++++++++++++++++++++++++++++++++++
Make.defines.freebsd
+++++++++++++++++++++++++++++++++++++++++

# Common make definitions, customized for each platform

# Definitions required in all program directories to compile and link
# C programs using gcc.

WKDIR=/home/seamus/apue.2e
CC=gcc
COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
LDDIR=-L../lib
LDLIBS=../lib/libapue.a $(EXTRALIBS)
CFLAGS=-ansi -I$(WKDIR)/include -Wall -DBSD $(EXTRA)

# Our library that almost every program needs.
LIB=../libapue.a

# Common temp files to delete from each directory.
TEMPFILES=core core.* *.o temp.* *.out typescript*

+++++++++++++++++++++++++++++++++++++++++
pracct.c
+++++++++++++++++++++++++++++++++++++++++

#include "apue.h"
#include <sys/acct.h>

#ifdef HAS_SA_STAT
#define FMT "%-*.*s  e = %6ld, chars = %7ld, stat = %3u: %c %c %c %c\n"
#else
#define FMT "%-*.*s  e = %6ld, chars = %7ld, %c %c %c %c\n"
#endif
#ifndef HAS_ACORE
#define ACORE 0
#endif
#ifndef HAS_AXSIG
#define AXSIG 0
#endif

static unsigned long
compt2ulong(comp_t comptime)    /* convert comp_t to unsigned long */
{
    unsigned long    val;
    int                exp;

    val = comptime & 0x1fff;    /* 13-bit fraction */
    exp = (comptime >> 13) & 7;    /* 3-bit exponent (0-7) */
    while (exp-- > 0)
        val *= 8;
    return(val);
}
int
main(int argc, char *argv[])
{
    struct acct        acdata;
    FILE            *fp;

    if (argc != 2)
        err_quit("usage: pracct filename");
    if ((fp = fopen(argv[1], "r")) == NULL)
        err_sys("can't open %s", argv[1]);
    while (fread(&acdata, sizeof(acdata), 1, fp) == 1) {
        printf(FMT, (int)sizeof(acdata.ac_comm),
            (int)sizeof(acdata.ac_comm), acdata.ac_comm,
            compt2ulong(acdata.ac_etime), compt2ulong(acdata.ac_io),
#ifdef HAS_SA_STAT
            (unsigned char) acdata.ac_stat,
#endif
            acdata.ac_flag & ACORE ? 'D' : ' ',
            acdata.ac_flag & AXSIG ? 'X' : ' ',
            acdata.ac_flag & AFORK ? 'F' : ' ',
            acdata.ac_flag & ASU   ? 'S' : ' ');
    }
    if (ferror(fp))
        err_sys("read error");
    exit(0);
}






More information about the freebsd-questions mailing list