Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.