1566 Compile errors with just two characters!
When programmers have to explain why it took longer to get something working,you don’t often here reasons like this. A simple syntax error error took me an hour to find and fix. Yet it does happen and it happened to me today.
Oh sure you feel silly afterwards and it was only a 131 lines of C code. The very last of the 1566 compile errors was unexpected end-of-file found on line 132. That was a red herring of sorts. The error actually occurred right at the start of the program.
Here’s the first 10 lines. It should be quite easy to spot but when you are looking through 130 lines with a hint that it’s messed up the end of the file, it’s not so obvious.
// tictactoe.c
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
int playerIsX, computerFirst, x, y, danger, turn;
char board[3][3]; // holds X, O and space
char playerPiece, computerPiece;
In case you haven’t spotted it, it’s the missing .h; it should be string.h not string in that 3rd #include. An obvious-in-hindsight clue is the error listing. The files that are mentioned don’t have .h on them. (cctype, cstdint etc. Those are C++ files and string is a C++ header file. Also mention of namespace in the error message is also a big hint.
Still I think that sets a record for the most errors generated in a C compile! The compiler btw was Visual Studio 2019’s C/C++ compiler.


You can’t return anything from a constructor. One way is to use exceptions but those can bring their own issues. Google’s C++ guidelines actually stipulate no exceptions and I’ve heard it from others as well that they prefer not to use them. Some people avoid it by having a mostly empty constructor and then an init() method to do the real initialisation and return a success/fail state.
I made the mistake of starting by trying to convert the final version of Asteroid; all 2,200 lines of C into C++.
Reading the temperature of a Raspberry PI can be done in a couple of ways. This command:
If you have a bit of nesting and you want to make sure your braces match up, Visual Studio code (VSC) can help you with that.
