Date: Mon, 2 Aug 2004 02:39:22 +0200 From: Simon Barner <barner@in.tum.de> To: Josh Paetzel <friar_josh@tcbug.org> Cc: questions@freebsd.org Subject: Re: Way OT programming question Message-ID: <20040802003922.GE1183@zi025.glhnet.mhn.de> In-Reply-To: <200408011829.58952.friar_josh@tcbug.org> References: <200408011829.58952.friar_josh@tcbug.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <sys/cdefs.h> > __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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040802003922.GE1183>