From owner-freebsd-questions@FreeBSD.ORG Mon Aug 2 00:39:24 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E6F816A4CE for ; Mon, 2 Aug 2004 00:39:24 +0000 (GMT) Received: from tuminfo2.informatik.tu-muenchen.de (tuminfo2.informatik.tu-muenchen.de [131.159.0.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5C0D43D49 for ; Mon, 2 Aug 2004 00:39:23 +0000 (GMT) (envelope-from barner@in.tum.de) Received: by zi025.glhnet.mhn.de (Postfix, from userid 1000) id A41F03FEC; Mon, 2 Aug 2004 02:39:22 +0200 (CEST) Date: Mon, 2 Aug 2004 02:39:22 +0200 From: Simon Barner To: Josh Paetzel Message-ID: <20040802003922.GE1183@zi025.glhnet.mhn.de> References: <200408011829.58952.friar_josh@tcbug.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TU+u6i6jrDPzmlWF" Content-Disposition: inline In-Reply-To: <200408011829.58952.friar_josh@tcbug.org> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at informatik.tu-muenchen.de cc: questions@freebsd.org Subject: Re: Way OT programming question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2004 00:39:24 -0000 --TU+u6i6jrDPzmlWF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Josh Paetzel wrote: > I've been muddling through some of the source files for FreeBSD=20 > 5.2.1-RELEASE, and I've noticed that a large number of .c files=20 > in /usr/src have something similar to below in them: >=20 > #ifndef lint > #if 0 > static char sccsid[] =3D "@(#)cat.c 8.2 (Berkeley) 4/27/95"; > #endif > #endif /* not lint */ > #include > __FBSDID("$FreeBSD: src/bin/cat/cat.c,v 1.29 2003/04/30 17:40:28=20 > obrien Exp $"); >=20 > 1) Isn't 'if 0' always negative? Yes, has the same effect as using comments. I don't know why #if 0 was used here, but the line was probably kept in order to document the (version) history of the file. > 2) What is the __FBSDID line doing? It has the same purpose as the static char sccsid[] line: Each and every source file adds an id line to the resulting binary executable. Thus it is possible to determine the exact version of file. Example: % ident /bin/ls /bin/ls: $FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.6 2002/05/15 04:19:49 obrien= Exp $ $FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.5 2002/05/15 04:19:49 obrien= Exp $ $FreeBSD: src/lib/csu/common/crtbrand.c,v 1.4 2003/10/17 15:43:13 pete= r Exp $ $FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.12 2003/01/26 23:14:47 markm= Exp $ $FreeBSD: src/bin/ls/cmp.c,v 1.12 2002/06/30 05:13:54 obrien Exp $ $FreeBSD: src/bin/ls/ls.c,v 1.75 2003/12/01 19:10:29 obrien Exp $ $FreeBSD: src/bin/ls/print.c,v 1.66 2003/10/16 07:07:20 tjr Exp $ $FreeBSD: src/bin/ls/util.c,v 1.32 2003/09/09 12:02:52 tjr Exp $ Btw: ident(1) also works on source files, Makefiles -- basically everything that has a CVS id line. __FBSDID is defined in /usr/src/sys/sys/cdefs.h Simon Btw: While reading the FreeBSD source can be very interesting, browsing the commit logs can be even more exciting: You can either use `cvs log' directly (on your local copy of the repository or via anoncvs), or use the web interface at http://cvsweb.FreeBSD.org. --TU+u6i6jrDPzmlWF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFBDY06Ckn+/eutqCoRArxwAJ9I2ZefVyWG7jYYmhaEistqEyt0YgCeJh93 +gVPrxKliussGMzpr6Nl2Aw= =TG9X -----END PGP SIGNATURE----- --TU+u6i6jrDPzmlWF--