This topic is 4446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

You contstantly see applications with the Build number on them, like for example Xbox Media Center..it's currently on build like 5801 or something...I'm curious when people put that build number on them, are they keeping track of that themselves? or does the compiler do it? I'm curious because I have a bunch of applications that I constantly update and put on different computers, and I always get into trouble where some computers are using an older version and I forgot to update it, or I didn't put a place in the code for the version number. I realize for the bigger apps you build like auto updaters or something like that, but it hardly makes any sense to build something like that when the application itself only takes about 10 minutes to write. So I guess i'm looking for a solution to this, what do you guys do? Does everyone keep track of it all themselves? Thanks a bunch, ArchG

##### Share on other sites
They might get that build number from SVN and CVS systems. I am sure that is one potential way to do such a thing. I believe there is some visual studio plugins that would automate such as a task as well.

##### Share on other sites
I've generally seen it done with a #define in the code (EDIT: this version number should also go into any data files the system creates so you can detect if your loading data thats created with an older or newer version of the S/W). There is then label with the same name in perforce, or whatever, which is created when the new version goes online. Changing the version number is generally not something that can be automated, as it requires some intelligence.

Having a define is handy for libraries, as during the transition from one version to the next you can do stuff like...

#if MY_VERSION_NUM>2001  FancyNewFunction(this, that, theother);#else  //Note: Obsolete code, should be deleted  CrappyOldFunction(this, that);#endif

##### Share on other sites
The way I do it for the project I am responsible for (it is a significant component of a large system) is use the current top change list number as the version. I have a simple line in my makefile that does something like the following (it is slightly more elaborate than this, but you should get the idea):

p4 changes -m 1 //depot/project_name | awk '{ print "#define BUILD_VERSION "; print $2; print ";" }' > version.h All this does is create a header with a define for the build version. If I were to do a build number that was public (i.e. not based on my actual revision control number), I would just have a text file that lived at the top of the tree (that also goes through revision control) and have tools to increment this value, but ultimately generate a similar header with the version number. This particular idea is platform independent, but the implementation of the idea will be very build environment specific. Care must also be taken that this header is not included everywhere (only in relevant subsystems, perhaps have a utility library that has a version accessor function so only the version utility library has a dependancy on the generated version.h header in order to prevent full rebuilds every time. My$0.02

##### Share on other sites
one way of doing it is to run a little program before compiling that takes the version number from a source file, increments it and then saves it back.

There are IDEs out there that lets you specify programs to run before and after compilation.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
12

• 9
• 21
• 13
• 9
• 17
• ### Forum Statistics

• Total Topics
632608
• Total Posts
3007391

×