Fox Mulder
Fox Mulder

Reputation: 11

Automatic version numbers work in Visual Studio express c++ using macros

How to I setup a Macro or template that will automate version numbers

Eg

A source code will contain

Major Version Number 1.0. Minor Version Number 0.0. build 0.0 revision 0.0

So, when I compile source code files above numbers will auto update.

Any suggestions?

Upvotes: 1

Views: 270

Answers (1)

Mats Petersson
Mats Petersson

Reputation: 129524

The typical way to support build numbers and other "automatically updates of what version a file is", is to use an external program that writes the content to a version.h or similar.

I used to have a little program that did this for me, and it would update the version from 1.0-00A to 1.0-00B, and so on until 1.0-99Z if necessary [but usually I'd change it to 1.1-00A or something like that long before that].

Another variant uses your version control system to grab the "what source version is it", nearly all version control systems have a way to give you a number for the current version of the source ("changeset number" in mercurial, "short hash" in git, "changelist number" in clearcase, "revision" in SVN, etc).

Either way, you need some sort of script or program to run as part of your build, that updates your file that gets included as part of the build. In a makefile this is very easy, but most other build systems have some way to "run this {before, after} build".

Upvotes: 3

Related Questions