Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the RCSID with dollar signs as the first and last characters mean in FreeBSD code like touch.c?

Tags:

c

freebsd

See https://opensource.apple.com/source/file_cmds/file_cmds-82/touch/touch.c Line36:

__RCSID("$FreeBSD: src/usr.bin/touch/touch.c,v 1.20 2002/09/04 23:29:07 dwmalone Exp $");

What does this line mean? What is __RCSID and what is the meaning of the string? Is this some standard message for version control?

In cdefs.h I found

#ifndef __RCSID
#define __RCSID(s) __IDSTRING(rcsid,s)
#endif

and

#define __IDSTRING(name, string) static const char name[] __used = string

But I still don't know what they are for.

like image 929
Michael Ma Avatar asked Oct 18 '25 09:10

Michael Ma


1 Answers

This comes from the Revision Control System, one of the earliest version control systems, and later adopted by some other version control systems. If a file contains a string of the form $keyword:...$, the .. portion is replaced automatically by information about the version of the file when the file is checked in and out.

This is typically put into a static variable so that you can then search the resulting object file for the string, to find out what version of the source code was used to generate it. See the ident command for how this is used.

I checked some of my Linux systems and they don't have ident, but you can simply use strings:

strings /usr/bin/touch | grep FreeBSD:
like image 121
Barmar Avatar answered Oct 20 '25 23:10

Barmar