Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting Version Info into Comment Block
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/2253953/how-do-i-embed-mercurial-tags-into-my-c-c-code">How do I embed Mercurial tags into my C/C++ code?</a> </p> </blockquote> <p>Can I add version control info from Mercurial into the 1st comment block in the .c and .h files that the repo is tracking?</p> <p>I assume it will involve adding something to the Makefile, such that a comment line in the source files gets substituted on each compilation with the latest version information</p> <p>I have got as far as passing in a #define from the compiler (e.g. gcc -D) and have added the following to my Makefile:</p> <pre><code>HGVERSION:= $(shell hg parents --template 'hgid: {node|short}') CFLAGS += -g -Wall -DHGVERSION="\"${HGVERSION}\"" </code></pre> <p>but although this makes the preprocessor variable available to me, I'm not sure this helps with inserting some text into a comment block.</p> <p>To elaborate, I can see how I can use HGVERSION to implement say a -ver flag to get the exe to printout its version info, but I can't see how to get that info into the actual text of the source files</p> <p>To elaborate, I can see how I could use HGVERSION to implement some sort of programatic version information, e.g. printing the version when running the exe with a -ver flag or something like that, but not how I can get that info into the actual source file text in some way</p> <p>I'd like to end up with something like this at the top of each of my src files:</p> <pre><code>/* some comments * * version x.y.z */ </code></pre> <p>Am I on the right track or is some other technique required here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload