请参阅https://opensource.apple.com/source/file_cmds/file_cmds-82/touch/touch.c第 36 行:
__RCSID("$FreeBSD: src/usr.bin/touch/touch.c,v 1.20 2002/09/04 23:29:07 dwmalone Exp $");
Run Code Online (Sandbox Code Playgroud)
这行是什么意思?该字符串是什么__RCSID以及它的含义是什么?这是版本控制的一些标准消息吗?
在cdefs.h我发现
#ifndef __RCSID
#define __RCSID(s) __IDSTRING(rcsid,s)
#endif
Run Code Online (Sandbox Code Playgroud)
和
#define __IDSTRING(name, string) static const char name[] __used = string
Run Code Online (Sandbox Code Playgroud)
但我还是不知道它们是做什么用的。
这来自最早的版本控制系统之一的修订控制系统,后来被其他一些版本控制系统采用。如果文件包含 形式的字符串$keyword:...$,则..在签入和签出文件时,该部分将自动替换为有关文件版本的信息。
这通常被放入静态变量中,以便您可以在生成的目标文件中搜索该字符串,以找出用于生成该字符串的源代码版本。请参阅ident命令了解如何使用它。
我检查了我的一些 Linux 系统,它们没有ident,但你可以简单地使用strings:
strings /usr/bin/touch | grep FreeBSD:
Run Code Online (Sandbox Code Playgroud)