*BSD News Article 48416


Return to BSD News archive

Path: sserve!euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!agis!news1.best.com!blob.best.net!not-for-mail
From: dillon@best.com (Matt Dillon)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Simple BSD code acting funny in FreeBSD (correctly in Linux)
Date: 9 Aug 1995 15:22:38 -0700
Organization: Best Internet Communications, Inc. (info@best.com)
Lines: 41
Distribution: world
Message-ID: <40bcfe$2pq@blob.best.net>
References: <DD06CB.It1@midway.uchicago.edu>
NNTP-Posting-Host: blob.best.net

:In article <DD06CB.It1@midway.uchicago.edu>,
:Frank S. Fejes <frank@gsb13580.uchicago.edu> wrote:
:>     Hello, I have been attempting to compile and run a simple ls-type
:>program under FreeBSD.  It is very simple Berkeley Unix C coding, but
:>I have run into a small problem running it under FreeBSD (it works
:>perfectly in Linux, though).  The problem lies in the ctime function 
:>and I am wondering if perhaps FreeBSD or BSD 4.4 has been changed a bit.
:>Here is a snippet from the program:
:>
:>    printf("%7d %.12s ", sbuf.st_size, ctime(&sbuf.st_mtime)+4);
:>
:>Here is a sample of the output when running the compiled binary under
:>FreeBSD (NULL replaces what should be the date last modified):
:>
:> 3056 drwxr-xr-x 19   1001/100      2048 (NULL) .
:> 2048 drwxr-xr-x  6   1001/0        1024 (NULL) ..
:> 1723 -rw-------  1   1001/100       329 (NULL) .cshrc
:...

    This one's easy... some <insert naughty word here> blasted
    <insert another word here> decided to change the
    size of off_t from a 32 bit longword to a 64 bit quadword.

    This coupled with the fact that the compiler does NOT spew out 
    implcit function declaration warnings by default makes for a very
    bad combination... it has caused us countless hours of pain and probably
    a lot of other people too.  And I mean real pain... it's bad when you
    compile a program and get no errors or warnings yet the generated code
    is so completely *wrong*, couple with the fact that many popular programs
    such as pop3 and others that manipulate files wind up totally and
    irrevocably corrupting said files when compiled without modification.

    You have to compile -Wall and fix any 'implicit declaration of function'
    warnings by #include'ing the appropriate header file. 

						-Matt

-- 
    Matthew Dillon   VP Engineering, BEST Internet Communications, Inc.
		    <dillon@best.com>, <dillon@apollo.west.oic.com>
    [always include a portion of the original email in any response!]