2007-12-16 22:20:24 +00:00
|
|
|
It is 4 spaces, no tabs, preferrably at 80 columns per line.
|
|
|
|
|
|
|
|
The preferred coding style is explained by example.
|
|
|
|
|
|
|
|
Source file example:
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright
|
|
|
|
LICENSE TEXT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "foo.h"
|
|
|
|
|
|
|
|
#include "bar.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2008-04-16 23:39:07 +00:00
|
|
|
void
|
|
|
|
foobar (FooEnum bar, const gchar* foo)
|
2007-12-16 22:20:24 +00:00
|
|
|
{
|
|
|
|
if(!foo)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef BAR_STRICT
|
2008-03-10 21:26:09 +00:00
|
|
|
if (bar == FOO_N)
|
2007-12-16 22:20:24 +00:00
|
|
|
{
|
2008-03-10 21:26:09 +00:00
|
|
|
g_print ("illegal value for 'bar'.\n");
|
2007-12-16 22:20:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// this is an example
|
|
|
|
gint n;
|
2008-03-10 21:26:09 +00:00
|
|
|
switch (bar)
|
2007-12-16 22:20:24 +00:00
|
|
|
{
|
|
|
|
case FOO_FOO:
|
|
|
|
n = bar + 1;
|
|
|
|
break;
|
|
|
|
case FOO_BAR:
|
|
|
|
n = bar + 10;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
n = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint i;
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
2007-12-16 22:20:24 +00:00
|
|
|
{
|
2008-03-10 21:26:09 +00:00
|
|
|
g_print ("%s\n", foo);
|
2007-12-16 22:20:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Header file example:
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright
|
|
|
|
LICENSE TEXT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FOO_H__
|
|
|
|
#define __FOO_H__ 1
|
|
|
|
|
|
|
|
#ifdef HAVE_BAR_H
|
|
|
|
#define BAR_STRICT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// -- Types
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FOO_FOO,
|
|
|
|
FOO_BAR,
|
|
|
|
FOO_N
|
|
|
|
} FooEnum;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-03-10 21:26:09 +00:00
|
|
|
FooEnum foo_bar;
|
2007-12-16 22:20:24 +00:00
|
|
|
} FooStruct;
|
|
|
|
|
|
|
|
// -- Declarations
|
|
|
|
|
|
|
|
void
|
2008-03-10 21:26:09 +00:00
|
|
|
foo_bar (FooEnum bar,
|
|
|
|
const gchar* foo);
|
|
|
|
|
|
|
|
const gchar*
|
|
|
|
foo_foo (FooStruct foo_struct,
|
|
|
|
guint number,
|
|
|
|
gboolean flag);
|
2007-12-16 22:20:24 +00:00
|
|
|
|
|
|
|
#endif /* !__FOO_H__ */
|