Product SiteDocumentation Site

Chapter 2. C Coding Guidelines

Table of Contents

2.1. C Boilerplate
2.2. Formatting
2.2.1. Whitespace
2.2.2. Line Length
2.2.3. Pointers
2.2.4. Functions
2.2.5. Control Statements (if, else, while, for, switch)
2.2.6. Operators
2.3. Naming Conventions
2.4. vim Settings

2.1. C Boilerplate

Every C file should start like this:
/*
 * Copyright (C) <YYYY[-YYYY]> Andrew Beekhof <andrew@beekhof.net>
 *
 * This source code is licensed under <LICENSE> WITHOUT ANY WARRANTY.
 */
<YYYY> is the year the code was originally created (it is the most important date for copyright purposes, as it establishes priority and the point from which expiration is calculated). If the code is modified in later years, add -YYYY with the most recent year of modification.
<LICENSE> should follow the policy set forth in the COPYING file, generally one of "GNU General Public License version 2 or later (GPLv2+)" or "GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)".