Compiling for Windows & destroying motivation

A few days ago I tried to set-up a Windows 7 build vm and compile SpaceShooter in VisualStudio.

This resulted in a massive drop in my motivation due to a real depressing discovery: the Visual Studio compiler has horribly obsolete support for C.

Microsoft Visual Studio and (lack of) C standards

I set up the Visual Studio project and tried to compile and what awaited me was about 50 errors, way more then I would expect for a simple program.

Worse, the errors were cryptic and didn’t really explain the problem.

After searching the net for what these errors mean, I found the problem wasn’t really the code, it was the compiler.

It turns out that the Visual Studio doesn’t support either the C11 or C99 standards leaving it left with only c90 support.

Now the C90 standard is 24 years old (25 if you count the fact that it was actually developed in 1989) and quite a few things have been changed and added since then.

Microsoft also have stated that they will not add support for C99 (and C11) as they consider C to be a dead language.

What does that mean for me?

What it meant was that if I planned on compiling with Visual Studio I had to adapt my code to support the C90 standard.

For me it meant a few things, firstly all instances where I was assigning values to structs I had to do it property by property instead of using a quicker syntax.

For example:

pos = (struct Point){5,6};

had to be changed to:

pos.x = 5;
pos.y = 6;

This might not seem to be a big issue, but when you have a struct with 8 properties, 3 of which are structs with 2 properties that ends up being 11 lines of code instead of 1.

On the other hand having the properties set individually makes it easier when adding new properties and maintenance so it was probably a good idea to fix that anyway.

The other problem was that the C90 standard requires all variables to be defined at the top of the scope. This issue I have a problem with, I believe code is more readable/understandable when they are declared close to where they are used.

There was one last minor issue, the round() function that I was calling doesn’t exist in the C90 standard (it was added in the C99 standard), but it was easily fixed with a quick self-defined version of the function:

double round(double val) {
    return floor(val + 0.5);
}

 Compiling without Visual Studio

After I changed all the code to support C90, I then decided to not support C90 (yes a bit late I know). That meant finding an alternative compiler.

I decided to set an a MinGW environment and use gcc (a proper compiler) and a Makefile to build the Windows version.

But gcc didn’t like to compile because the version of the library I had was compiled under Visual Studio.

I could have easily gotten the correct version but because the versions available for gcc on MinGW but since the version number of the available binaries was lower then the one I was using on Mac OSX (5.0 and 5.1 respectively) and there were some slight differences, I chose to try and compile it from the source.

Again I was stopped, this time it was the DirectX SDK that wouldn’t install, and the error was saying that the Microsoft Visual C++ Redistributable was already installed.

Two issues here:

  1. It wasn’t installed
  2. So what if it was? Why does the installer for the DirectX SDK “need” to install the C++ Redistributable itself, if its already installed can’t it detect that and skip that step rather then dying???

Motivation destroyed

And so that was it, I had had enough of Microsoft and their motivation sucking stupidity. It had made me so frustrated that it stopped my progress.

I now have continued work on my game and will forget about a Windows version.

If I have enough time at the end of the month I might try again but for now the very though of trying again just makes me annoyed.

Leave a Reply

Your email address will not be published. Required fields are marked *