Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Post Build command line (VS.Net 2003)

Status
Not open for further replies.

LuckyLuke

Programmer
Mar 28, 2001
188
NL
Hi,

I made a small program which calculates the CRC of the main file and inserts data along with the CRC inside a custom made data section in the main application. It doesn't really matter much how it works, because the problem is simply building the right command line.

The command line should look like this:

CRC32.exe [Target] [Section] [Offset] [Size]

Well I know the values so I can simply give (for instance) this command line in VS:

CRC32.exe "$(TargetPath)" ".SECSEG" "208" "1024"

However I just don't like 'hardscribing' the last three values in the command line. For each of the values I have a predefined value which is known to the preprocessor. Is it possible to pass those values along in the command line? For instance:

#define CRC_SECTION ".SECSEG"
#define CRC_OFFSET 208
#define CRC_BLOCKSIZE 1024

CRC32.exe "$(TargetPath)" "$(CRC_SECTION)" "$(CRC_OFFSET)" "$(CRC_BLOCKSIZE)"

Obviously the above command line doesn't work, but it's just to illustrate my intentions. I don't know if this is possible at all, but I was just wondering if it is.

Thanks in advance.
 
You can not define make macros like this. I htink you can define make macros like below, it is correct at least for make files:
CRC_SECTION = ".SECSEG"


Ion Filipski
1c.bmp
 
Yes figured as much. The thing is that I want to have those macro's in sync with the defines in my code. Is it perhaps possible to do it in visual studio automation?
 
I don't believe what this is possible. You can pass in command to the compiller the -DsomeSefineMacros, but not in postbuild events. This macros will be 'visible' in your code, so you can use

#if defined(someSefineMacros)
....
#endif

Ion Filipski
1c.bmp
 
You could store your values as environment variables, which can be passed to the compiler, and via make to the command line of your utility.

For example
Code:
int main(void) {
  printf("Hello %s\n",MYBAR);
  return 0;
}
In the project properties for this file, I added
Code:
MYBAR=\"$(USERNAME)\"
to the pre-processor definitions.
The resulting program prints your login name (at the time of the build).

Running your utility would follow the same style, say
Code:
echo all done $(USERNAME)


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top