<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Source code header question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938159#M100192</link>
    <description>In understanding the options here you may wish to look at the man pages for "ident" and "what" as tools for extracting version strings from binaries and scripts.&lt;BR /&gt;&lt;BR /&gt;Tools like cvs can be used to automatically update version strings in source file.  For scripts you can just have the $Header entry in comments but if you want the header to to persisist into binaries and executables it needs to be a statically defined string so it does not get stripped out.&lt;BR /&gt;&lt;BR /&gt;Here is a string that has been inserted by cvs into a Perl script:&lt;BR /&gt;&lt;BR /&gt;# "$Header: /opt/cvs/CCT/scripts/sendMime.pl,v 1.1 2005/10/26 05:19:58 daavid Exp $";&lt;BR /&gt;&lt;BR /&gt;In some of my make files I have them append a line to a source file which is the name of the final compiled binary, so that it will always be updated in the cvs repository. The only "source" in this file is the statically defined string.  This automatically maintains the version number for the binary every time the code is updated in cvs.  A combination of ident and grep quickly and reliably allows this version number to be extracted.  eg (this binary is called "legacy"):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ident legacy | grep legacy&lt;BR /&gt;legacy:&lt;BR /&gt;     $Header: /opt/cvs/CCT/servers/legacy/legacy.cpp,v 1.38 2005/05/24 03:12:38 daavid Exp $</description>
    <pubDate>Thu, 03 Nov 2005 22:48:53 GMT</pubDate>
    <dc:creator>Daavid Turnbull</dc:creator>
    <dc:date>2005-11-03T22:48:53Z</dc:date>
    <item>
      <title>Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938152#M100185</link>
      <description>Many source code files have something like the following statement at the beginning:&lt;BR /&gt;&lt;BR /&gt;#ifndef lint&lt;BR /&gt;static char ModuleId[] = "@(#)FTAM: ftm_conn.c $Revision: 9.1 $ $Date: 94/11/17 17:36:21 $";&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;What does this mean? It looks strange. And the time was so accurate. Is this generated by some program?&lt;BR /&gt;Please help!&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;Fei</description>
      <pubDate>Thu, 03 Nov 2005 02:39:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938152#M100185</guid>
      <dc:creator>Fei Rao</dc:creator>
      <dc:date>2005-11-03T02:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938153#M100186</link>
      <description>This is generated by lint or splint, Splint is a tool for statically checking C programs for security vulnerabilities and coding mistakes. With minimal effort, Splint can be used as a better lint. If additional effort is invested adding annotations to programs, Splint can perform stronger checking than can be done by any standard lint.  &lt;BR /&gt;&lt;BR /&gt;If you want for HP-UX 11i, download from &lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Development/Tools/lclint-2.5q/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Development/Tools/lclint-2.5q/&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.splint.org/" target="_blank"&gt;http://www.splint.org/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Thu, 03 Nov 2005 02:48:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938153#M100186</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-11-03T02:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938154#M100187</link>
      <description>Can this tool be used to check programs in C++? and the string written by human or generated automatically? I have no idea about it.</description>
      <pubDate>Thu, 03 Nov 2005 03:06:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938154#M100187</guid>
      <dc:creator>Fei Rao</dc:creator>
      <dc:date>2005-11-03T03:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938155#M100188</link>
      <description>Yes, You can use for C++ programs. Strings are generated by the program itself. &lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Thu, 03 Nov 2005 03:57:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938155#M100188</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-11-03T03:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938156#M100189</link>
      <description>Could you give me a simple example? My MSN is: fera_bill@hotmail.com. Welcome to be my friend!&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 03 Nov 2005 04:05:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938156#M100189</guid>
      <dc:creator>Fei Rao</dc:creator>
      <dc:date>2005-11-03T04:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938157#M100190</link>
      <description>I think Arunvijai's explanation was not entirely correct.&lt;BR /&gt;&lt;BR /&gt;The construction "#ifndef lint" ... "#endif" means that the lines between them are excluded when a macro named "lint" is defined. &lt;BR /&gt;&lt;BR /&gt;Source code analyzers like lint and splint define that macro to allow the programmer to exclude things that would confuse the analyzer program and produce useless error messages.&lt;BR /&gt;&lt;BR /&gt;The "static char ModuleId[] = ..." line looks like it contains automatic version numbering directives. These are used when the source code is stored in an automated version control system, like RCS, CVS, Subversion, BitKeeper and others. When this kind of software is used, it is often said that the source code is in a "repository".&lt;BR /&gt;&lt;BR /&gt;The programmer writes just the "$Revision: $" and "$Date: $" parts. The revision control system automatically increments the version numbers and updates the date/time values each time the programmer stores a changed version of the file into the repository. This is often called a "commit".&lt;BR /&gt;&lt;BR /&gt;Because the string is declared as a static one-dimensional table of characters (a string in C programming language), this string gets included in the compiled program, even if it is not actually used anywhere in the program code. &lt;BR /&gt;&lt;BR /&gt;When a program is being tested, the testers may need to know which exact version of each source code file was used in compiling the program. This is just a way to embed the information in the program binary.&lt;BR /&gt;&lt;BR /&gt;You can check it out yourself: on most unix-like operating systems you can try to extract all the readable strings from a program binary using the "strings" command. &lt;BR /&gt;For example, on HP-UX 11.11 I can enter the command:&lt;BR /&gt;&lt;BR /&gt;strings /bin/ls |more&lt;BR /&gt;&lt;BR /&gt;The first line contains a text that looks familiar:&lt;BR /&gt;$Revision: 92453-07 linker linker crt0.o B.11.16 000601 $&lt;BR /&gt;&lt;BR /&gt;Because it mentions "linker" and "crt0.o" I believe this tells us the version of the C compiler used in producing the "ls" command. &lt;BR /&gt;&lt;BR /&gt;On HP-UX, you might need the "-a" option to get all the strings in the program:&lt;BR /&gt;&lt;BR /&gt;strings -a /bin/ls |more&lt;BR /&gt;&lt;BR /&gt;Now you get (among other things) something like this:&lt;BR /&gt;ls.c $Date: 2003/03/13 02:04:47 $Revision: r11.11/2 PATCH_11.11 (PHCO_27415)&lt;BR /&gt;$Revision: @(#) all CUP11.11_BL2003_0504_1 PATCH_11.11 PHCO_27415\n @(#) Sun May  4 22:44:52 PDT 2003 $&lt;BR /&gt;&lt;BR /&gt;This describes the exact version of "ls" command source code, if someone ever needs to know.</description>
      <pubDate>Thu, 03 Nov 2005 04:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938157#M100190</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2005-11-03T04:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938158#M100191</link>
      <description>Oh, I think I can understand that now.&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;Fei</description>
      <pubDate>Thu, 03 Nov 2005 05:16:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938158#M100191</guid>
      <dc:creator>Fei Rao</dc:creator>
      <dc:date>2005-11-03T05:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938159#M100192</link>
      <description>In understanding the options here you may wish to look at the man pages for "ident" and "what" as tools for extracting version strings from binaries and scripts.&lt;BR /&gt;&lt;BR /&gt;Tools like cvs can be used to automatically update version strings in source file.  For scripts you can just have the $Header entry in comments but if you want the header to to persisist into binaries and executables it needs to be a statically defined string so it does not get stripped out.&lt;BR /&gt;&lt;BR /&gt;Here is a string that has been inserted by cvs into a Perl script:&lt;BR /&gt;&lt;BR /&gt;# "$Header: /opt/cvs/CCT/scripts/sendMime.pl,v 1.1 2005/10/26 05:19:58 daavid Exp $";&lt;BR /&gt;&lt;BR /&gt;In some of my make files I have them append a line to a source file which is the name of the final compiled binary, so that it will always be updated in the cvs repository. The only "source" in this file is the statically defined string.  This automatically maintains the version number for the binary every time the code is updated in cvs.  A combination of ident and grep quickly and reliably allows this version number to be extracted.  eg (this binary is called "legacy"):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ident legacy | grep legacy&lt;BR /&gt;legacy:&lt;BR /&gt;     $Header: /opt/cvs/CCT/servers/legacy/legacy.cpp,v 1.38 2005/05/24 03:12:38 daavid Exp $</description>
      <pubDate>Thu, 03 Nov 2005 22:48:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938159#M100192</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2005-11-03T22:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Source code header question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938160#M100193</link>
      <description>Got the idea.</description>
      <pubDate>Wed, 05 Jul 2006 01:05:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/source-code-header-question/m-p/4938160#M100193</guid>
      <dc:creator>Fei Rao</dc:creator>
      <dc:date>2006-07-05T01:05:15Z</dc:date>
    </item>
  </channel>
</rss>

