# VS2008 C++ Two Parter Questions (Get number of builds and is there a flash portable?)

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

## Recommended Posts

Is there a way in VS2008 that I can take a number of builds/compiles that where made and use that number in my source code as a int variable? Example:
#define BUILD_NUMBER  <NUM_OF_BUILDS>

int build_num = BUILD_NUMBER;
printf("This code was compiled %i time(s).", build_num);


The second part is. Is there a way to get the compiler of VS2008 only? So it can fit on a USB flash drive so if I go into school and I'm in the mood for coding I can work on my projects with only like a cmd compiler of VS2008? Thanks, Andrew.

##### Share on other sites
Hi Andrew

There is a very easy way to do exactly what you want. In Visual Studio there is an option in the project settings that allows you to do custom commands at specific time periods during your build. The way that I do it is that I have a custom program that will parse an input file for specific entries and the increment based upon the command line args. However, you could do it any way that you want.

The project setting that you are looking for is call "Build Events." I would suggest that you use the "Post-Build Event" option.

As for the second part of your question, I don't believe that there is an offical release of only the compiler. You have two options, you could simply download and install an Express Edition of VS on your school computers (if it is allowed). Or the second option is that you could simply try taking the compiler exe with you. However, this will only allow you to compile and not link, thus not being able to run your program. I believe that the executable is "cl.exe" located in VC\bin subfolder of you VS installation directory. But if you were to go this route you would need to have some sort of makefile that would translate all of your Visual Studio options and commands into command line arguments for the cl.

There is another option though. I believe that Code::Blocks (another IDE) is installable onto a USB key and has the option of supporting Visual Studio solution files.

I hope that his helps.

##### Share on other sites
Hm, I tried googling on use the post-build, but I don't see much on it except for the .NET side, witch I'm not using. I'm not sure how you want to me use it.

I'm going to use code::block it looks efficient and it's small enough, plus like you said I can import Visual Studio.

##### Share on other sites
The "Post-Build Event" in a sub property within the "Build Events" in the project property window. You can use any system commands to do what you want.

For example in my "Post-Build Event" Command line property I use the command "BuildVersion ..\..\..\Source\Omega\VersionNo.h" where the first is a program available on my computer and the second part is the command line argument that I pass into the program.

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009377
• ### Who's Online (See full list)

There are no registered users currently online

×