Programming Utilities Guide

Incorporating Version-Dependent Information by Using ID Keywords

As mentioned above, SCCS allows you to include version-dependent information in a checked-in version through the use of ID keywords. These keywords, which you insert in the file, are automatically replaced by the corresponding information when you check in your changes. SCCS ID keywords take the form:

%C%

where C is an uppercase letter.

For instance, %I% expands to the SID of the most recent delta. %W% includes the filename, the SID, and the unique string @(#) in the file. This string is searched for by the what command in both text and binary files (allowing you to see from which source versions a file or program was built). The %G% keyword expands to the date of the latest delta. Other ID keywords and the strings they expand to are listed in Table 5-1.


Note -

Defining a string in this way allows version information to be compiled into the C object file. If you use this technique to put ID keywords into header (.h) files, use a different variable in each header file. This prevents errors from attempts to redefine the (static) variables.


To include version dependent information in a C program, use a line such as:

static char SccsId[ ] = "%W%\t%G%";

If the file were named program.c, this line would expand to the following when version 1.2 is retrieved:

static char SccsId[ ] = "@(#)program.c 1.2 08/29/80";

Since the string is defined in the compiled program, this technique allows you to include source-file information within the compiled program, which the what command can report:

$ cd /usr/ucb
$ what sccs 
sccs
sccs.c 1.13 88/02/08 SMI

For shell and similar scripts, you can include ID keywords within comments:

#	%W%		%G% 
.  .  .

If you check in a version containing expanded keywords, the version-dependent information will no longer be updated. To alert you to this situation, SCCS gives you the warning:

No Id Keywords (cm7)

when a get, edit, or create finds no ID keywords.