WeeChat Coding Style

From FlashTux

Jump to: navigation, search
  • Use 4 spaces for indentation. Don't use leading tabs.
  • Don't use typedef for structures, but use them to define function prototypes.
  • Don't use C99-style comments like // foobar
  • Use explicit variable names, for example "nicks_count" instead of "n" or "nc".
  • sizeof(char) == 1. Even if char is not 8 bits, then sizeof(char) is still 1. That's what C standard say. If you need to count bits - use CHAR_BIT from limits.h
  • Functions:
/*
 * foo: foobars baz
 */

void
foo (void)
{
    bar (foo);
}
  • Look at space before round bracket in function calls.
if (something)
{
    foo ();
    bar (foo);
    baz (foo, bar);
}
  • Switch statement:
switch (var)
{
    case 1:
        foo ();
        break;
    case 2:
        bar ();
        break;
    default:
        baz ();
        break;
}
Personal tools