Table of Contents
/* * Copyright <YYYY[-YYYY]> the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under <LICENSE> WITHOUT ANY WARRANTY. */
<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+)".
#ifndef MY_HEADER_NAME__H # define MY_HEADER_NAME__H // header code here #endif // MY_HEADER_NAME__H
#ifdef __cplusplus extern "C" { #endif /*! * \file * \brief My brief description here * \ingroup core */ // header code here #ifdef __cplusplus } #endif
*
goes by the variable name, not the type:
char *foo;
*
and after the closing parenthesis in a cast:
char *foo = (char *) bar;
static int function_name(int bar, const char *a, const char *b, const char *c, void (*d)()) {
static int really_really_long_function_name_this_is_getting_silly_now( int bar, const char *a, const char *b, const char *c, const char *d) {
else
and else if
are on the same line with the ending brace and opening brace, separated by a space.
if
or while
conditionals. This ensures that the developer’s intent is always clear, making code reviews easier and reducing the chance of using assignment where comparison is intended.
a = f(); if (a < 0) { statement1; } else if (some_other_condition) { statement2; } else { statement3; }
switch
statement, case
is indented one level, and the body of each case
is indented by another level. The opening brace is on the same line as switch
.
switch (expression) { case 0: command1; break; case 1: command2; break; default: command3; }
x = a + b - (c * d);