views:

166

answers:

0

I want to have a version number string in my source files to keep track of the source version used for the build. I thought I had a solution for this, but it doesn't work consistently and I cannot figure out why.

The number I want to use is the subversion version as output by the svnversion command. I have written a Python script which runs as a pre-build event. It executes svnversion and puts the output into a file version.h with just one line

#define VERSION "1966"

The file that needs the version information then includes it

#include "version.h"

The problem is that if version.h changes the new file doesn't seem to get picked up by the including file unless I do a full rebuild. Incremental builds don't cause version.h to be re-read.

I thought perhaps the version.h file was not being written to disk in time so I did things like flush it and sync it. Doesn't help. I'm sure programmers do this kind of automated version updating all the time. Surely I'm missing something simple?