Coding Style Guide

Version: $Id: codingstyleguide.html,v 1.18 2001/12/11 13:54:01 hans Exp $

This document describes the advised coding style for internal code. When coding external stuff, stick to the external style. The style guide is a dynamic document: if we find that a certain style aspect should be changed (because it's ugly, impractical, strange, inconsistent, etc), it can and should be changed (after we agree on it, of course!).

At this moment we have a lot of legacy code, and it seems unlikely that this will change in the near future. Rewriting everything isn't really an option. Make new code clean, and keep it that way. (Comments & flak to [email protected])

We should be writing code that is cross platform. There are other people who do the same, and sometimes they have something usefull to say. Not all advice applies to our situation, so read with care.

Index

1. Introduction
2. Layout
2.1. Tab spacing, tabbing
2.2. Parenthesising
2.3. Multiple statments on one line
2.4. Linewidth
2.5. Writing comments
3. Names
3.1. Keywords and other reserved phrases
3.2. Platform identifiers
3.3. Write function prototypes
3.4. Variable and function names
3.5. Using Blender-libraries names
4. Type usage
4.1. Using booleans
4.2. Type conversions
4.3. Char and uchar types
4.4. Type widths
5. Statements and side-effects
5.1. Statements with side-effects
5.2. Functions with side-effects
6. Compiler/linker usage
6.1. Static code checks
6.2. Using dependencies for experimental code and port discrimination

1. Introduction

Coding styles serve the following purposes:

Per issue, the following points are treated:

2. Layout

2.1. Tab spacing, tabbing

2.2. Parenthesising

2.3. Multiple statments on one line

2.4. Linewidth

2.5. Writing comments

3. Names

3.1. Keywords and other reserved phrases

3.2. Platform identifiers

3.3. Write function prototypes

3.4. Variable and function names

3.5. Using Blender-libraries names

4. Type usage

4.1. Using booleans

4.2. Type conversions

4.3. Char and uchar types

4.4. Type widths

5. Statements and side-effects

5.1. Statements with side-effects

5.2. Functions with side-effects

6. Compiler/linker usage

6.1. Static code checks

6.2. Using dependencies for experimental code and port discrimination