Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to include svn version number into my C/C++ code. I found a way to do it in linux, but I also compile the code under Windows, where I don't use svn.

One way to do it would be to create a file svn.h, which is then included into the code. The file should contain the following line:

#define SVNVERSION "12345M"

Here 12345M is the output of the command svnversion. How to create such a file using bash script (or how to include the command into the Makefile)?

share|improve this question
echo '#define SVNVERSION "'$(svnversion .)'"' > svn.h

You may have to adjust svnversion . so it matches exactly what you write to get 12345M

share|improve this answer

AFAIR, SVN does keyword expansion, so you can get version numbers pasted in automatically on checkout.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .