Starting the Cube Project

Published on Jun 7, 2018

I haven't written C code for quite some time. I have never written it, suprisingly, on any *nix platform. (I only wrote it on my Amiga 500 with the Lattice C compiler.) For me, C was short lived. C++ became popular as I was getting my coding feet under me. Switching from C to C++ seemed like the right thing to do, especially since the early Windows APIs were C++. (The inability to purchase a new monitor for my Amiga after mine died necessitated the move to a Gateway machine with Windows 3.1.)

It feels strange, after all this time, to be returning to C. It feels like an old friend, and completely foreign at the same time. There have been three revisions (C89, C99, C11), an entirely new operating system (Linux) and tons of third party libraries have become available (libGlib, libXML2, etc). So why isn't there some consensus on how to structure a project?

I searched around a bit, found this Stack Overflow question and a few others, but none really had a definitive answer.

I suppose I've become soft. I'm too accustomed to rails new blah, bundle gem blah, npx create-react-app blah. It is handy to have that thinking done for you, to have many of the initial project decisions taken care of so you can get started coding right away. On the other hand, you are then saddled with those decisions for the life of the project.

You can only search around for 'the right thing to do' for so long. At some point you just have to DO something. The Cube project has been started. All of the project files were in the root directory for the first couple commits. Then I found the GNU Make vpath directive. It allows you to assign directories to file patterns like so:

vpath %.c src
vpath %.h include

That tells Make to search for files with a .c extension in a directory named src and files with a .h extension in a directory named include. Very handy. The project directory is significantly less cluttered now.

It is still very early, but it is on its way. A new programming language that no one asked for, no one needs and no one will likely use. This is going to be fun.