views:

81

answers:

2

I developed a Windows command line tool using C, and compiled it in VC++, sometimes back, and checked-in the source code. I cleaned the project before checking-in, which deleted the .exe , .obj files besides others. I continued to use the command line tool though.

After a couple of months, I checked out the source, compiled again, but the EXE generated is not matching with the earlier compiled version.

My question,

Does the executable generated by VC++ change with recompilation? Or Am I missing something?

+6  A: 

Looking at the answers in this question, there's no way to force VS to output the same binary each time. The compiler embeds some metadata such as the timestamp in the executable, which is why the binary file is not identical between compilations.

One of the answers there also linked to this MSDN blog post, which states:

... compiler writers are far more interested in generating correctly functioning code and generating it quickly than ensuring that whatever is generated is laid out identically on your hard drive. Due to the numerous and varied methods and implementations for optimizing code, it is always possible that one build ended up with a little more time to do something extra or different than another build did. Thus, the final result could be a different set of bits for what is the same functionality.

So, your answer is yes, the binary files are not bit-for-bit identical, but they should be functionally identical.

Mark Rushakoff
+1  A: 

I have same problem (with partial solution that wasn't rolled out yet, so it might not even work).

http://stackoverflow.com/questions/1180852/deterministic-builds-under-windows

Eugene