Link Search Menu Expand Document

Getting the template

To get the raw template you can just clone the following repository, in a directory of your choosing:

  • git clone git@github.com:umbc-cmsc421-sp2021/generic_template.git

When Project 1 is released, we will give you a copy of this template tailored to that project. You will NOT need to repeat the installation steps here. Just use it if you’ve already been through this guide.

Using the template

This time we are providing you with a template for your user-space project(s). The purpose of this template is to provide you with some configuration on some common tools. It is not to provide you with code structure.

You can use this template in 3 main ways:

  • No environment (i.e with just a text editor like vim, emacs, nano, etc)
  • With Visual Studio Code (includes some nice config)
  • With CLion (as some of you have used it before)

You can also integrate it with other IDEs/editors as well if you are familiar with them. In fact this would also work with visual studio as well, but your code won’t. If you do integrate it with something else, feel free to reach out on discord so we can add it to the repo.

Before we move on to the configuration you can use the interface bellow to read about your various options. Changing the menus here will also adjust the instructions you will see later on, to cut down on the clutter!

General goodies

This template comes pre-configured with some things. It uses editorconfig to provide some configuration options to your editor if it supports the format. For instance all indentation will be done with tabs of size 4 (I believe, don’t recall of the top of my head). This is not because I like tabs, but because the kernel uses that so this is a bit of getting used to it.

We also provide a clang-format file so you can auto format your code. The amount of bugs we see because of badly formatted code is honestly ridiculous. To that end we had you install clang-format during the setup, and now you can use it simply by calling:

clang-format -i ./src/*.{c,h}

This will format your code automatically according to the Kernel’s coding style. Again this is for practice purposes. If you find that this makes your code unreadable, I’ve got bad news for you. It was already unreadable and it means you need to re-think your approach. There is a hard limit of 80 characters per-line. If you get more than that you are probably nesting your code too much. This often causes MAJOR bugs. Solutions to that would be to restructure your approach. Maybe check your error conditions first and stop or decide the path ahead of time and have only one path of execution. Another solution is abstract logic into functions.

int thing = get_thing_from_user(user);

is much more readable AND maintainable than the following. And maintenance doesn’t mean you in two years. It means you on Sunday after spending the past week working on databases and you forgot what you wrote last Sunday:

for () {
    while() {
        if() {

        }
        else {
            if () {
                break;
            }
        }
    }
}