Visual Studio compiler woes

Recently, I’ve been working on getting one of our products compiled and tested on 64-bit Windows. In order to help with this, I’ve been given a nice, shiny, super-fast 64-bit machine running Windows XP Professional x64 Edition.

After getting the build working correctly on this machine, it was time to port over my changes to our build system, so that the 64-bit material would be available to our development and test teams. However, when I moved it over, I ran into a problem, and it was a bit of a mystery. When attempting to compile using the 64-bit C compiler shipped with Visual Studio 2005, I was getting return code -1073740966. Not really a descriptive error!

Searching for the error code on the ‘net came up with only one relevant entry, a post on MSDN. Unfortunately, the replies didn’t seem particularly relevant to my problem, so that turned into a dead end.

However, it turns out that if you convert the return code into hexadecimal, you can get a whole lot further. If you feel like showing off you can work this out yourself, but for those of us in a hurry, the Windows calculator does this pretty easily - make sure it’s in scientific mode, paste the decimal number in, and hit the ‘hex’ button. In the case of the return code above, that converts to FFFFFFFFC000035A. We can dump the first 8 characters, leaving us with 0xC000035A.

Microsoft describes how to interpret this return code in the Visual Studio documentation:

//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//  +---+-+-+-----------------------+-------------------------------+
//  |Sev|C|R|     Facility          |               Code            |
//  +---+-+-+-----------------------+-------------------------------+
//
//  where
//
//      Sev - is the severity code
//
//          00 - Success
//          01 - Informational
//          10 - Warning
//          11 - Error
//
//      C - is the Customer code flag
//
//      R - is a reserved bit
//
//      Facility - is the facility code
//
//      Code - is the facility's status code

In this case, the error code translates to C=11, R=0, Facility=0, Code=0×0035A, which you can then use to attempt to figure out what went wrong in conjunction with the Visual Studio documentation. However, the quickest way to figure out what the error means is to try sticking our hexadecimal value into your favourite search engine, such as Google, which brings up a whole load of information.

A quick poke around reveals that this error code actually means ‘Attempting to load a 64-bit application, however this CPU is not compatible with 64-bit mode.’

Turns out that the build machine wasn’t actually a 64-bit machine! I had been incorrectly trying to launch the 64-bit compiler, instead of launching the 32-bit compiler for x64 targets, and obviously, it wasn’t happy. (In my defense, I don’t have either physical or remote-desktop access to the machine in question, so I was assuming it was a 64-bit machine - and that assumption was wrong!)

So, if you’re seeing this error code, make sure you’re not trying to run a 64-bit app on a non-64-bit machine. But more importantly, if you’re seeing a similar, ten digit negative decimal error code from Visual Studio, you might be able to use the same procedure to figure out what your problem is.

Leave a Reply