Comparing MSVC vs Clang
I originally created Asteroids for Windows using Visual Studio 2017 Community Edition. Since then I’ve started the Clang version on Ubuntu and there haven’t been too many differences but there are just a few so in this post I’ll list what I’ve found so far.
Include Paths
On Windows, I was able to get away with #include <SDL.h> but on Linux, I’ve had to include the path so it’s #include <SDL2/SDL.h>. This was probably because I included the full path in the MSVC configuration.
Link Failures
The asteroids.c code in chapter 29 uses sin and cos for the first time and the linker was unhappy with that. So in tasks.json, I’ve explicitly had to add it into args, along with SDL2 and SDL2_image,
"args": [
"-g",
"${file}","${workspaceFolder}/Asteroids/hr_time.c",
"-o",
"${fileDirname}/asteroids",
"-lSDL2",
"-lSDL2_image",
"-lm"
],
That “-lm” does that for maths.
Safe functions
Microsoft has its own set of safe functions many with an _s and extra length parameter.
On Linux, there don’t seem to be so many.
So sprintf_s on Windows becomes snprintf.
fopen_s just becomes standard fopen
linux/time.h
As well as time.h in the includes, I needed to add linux/time.h as well.
I’ve done a snake game in the past for About. That’s the picture and today I’ve uploaded it complete with source to 
So my demo program runs fine when I run it from the terminal. It creates a SDL Window and blits lots of numbers, but if I try to start it in the debugger, it gets to this function and fails in the SDL_CreateWindowAndRenderer.
My Linux rewrite continues with progress as far as chapter 38.
I’ve used diff and merge tools since the year dot. They let you compare two files and see on what lines they differ. You can also copy individual or blocks of lines from one to the other; that’s the merge. My all-time favourite was the commercial Araxis Merge which did a three way comparison and could be controlled by COM. I did this to compare two code bases.


Match Three games have been around for the best part of a decade and have a basic mechanic of swapping two adjacent pieces to make a line up of three, four or five pieces which get removed.
What makes possible all of the fast graphics in SDL2 is really one instruction.