BarrelfishWiki

Barrelfish coding styles

Code formatting

Coding construct guidelines

Types:

Naming/organisation:

Return values:

Misc:

Example code

/** \brief This function does nothing of any significant purpose */
uintptr_t frongle_blarg(void *blah)
{
    if (blah) {
        return (uintptr_t)blah - PAGESIZE; // foo
    } else {
        assert(!"Badness!");
        return -1;
    }
}

Resources

Elisp code to add to .emacs file in home directory:

(defun maybe-barrelfish-offset ()
  (if (string-match "barrelfish" buffer-file-name)
      (setq c-basic-offset 4
            cmake-tab-width 4
            indent-tabs-mode nil)
    ()
    )
  )
(add-hook 'c-mode-hook 'maybe-barrelfish-offset)

(require 'column-marker)
(add-hook 'c-mode-hook (lambda () (interactive) (column-marker-1 80)))

This enforces 4-space indents and no TABs when the file path contains the name barrelfish and is C or cmake source code. It also sets a column marker (you need the file column-marker.el in your site-lisp path) at column 80, so you see what you type beyond that spot. Automatic filling of any line more than 80 characters long is possible as well, but not always aesthetic with C source code. This is why manual filling should be used with the help of the column marker.

If you haven't done so already, you should enable support for cmake-mode and mercurial-mode in Emacs by adding this to your .emacs file:

(setq load-path (cons (expand-file-name "/dir/with/cmake-mode") load-path))
(require 'cmake-mode)
(setq auto-mode-alist
      (append '(("CMakeLists\\.txt\\'" . cmake-mode)
                ("\\.cmake\\'" . cmake-mode))
              auto-mode-alist))

(require 'mercurial)

BarrelfishWiki: Programming_for_Barrelfish/CodingStyle (last edited 2012-12-14 16:49:35 by shindep)