On Monday, April 27, 2009, address@hidden wrote:
I know coding style is a rather personal matter, but it would be good
to agree on it to some extent ;)
- Function return value on its own line
- Indent by 2 spaces
- Braces on new lines
- Spaces before open parenthesis '('
- Spaces between the data type and pointer '*' argument instead of the
other way around (i.e., 'void *data' not 'void* data'
I've been wanting to turn off tabs altogether with editors, since it
can be annoying when editors don't agree on how many spaces a tab is.
I imagine the most important is just to have some consistency.
Cheers.
Josh
My preference would be:
$ indent -kr -prs -psl -i4 -nut
Translation:
- Kernighan & Ritchie style, plus:
- put a space after every '(' and before every ')'
- put the type of a procedure on the line before its name
- indentation by 4 spaces
- no tabs
Sample code:
fluid_thread_t *
new_fluid_thread( fluid_thread_func_t func, void *data, int detach )
{
GThread *thread;
GError *err = NULL;
g_return_val_if_fail( func != NULL, NULL );
thread =
g_thread_create( ( GThreadFunc ) func, data, detach == FALSE,
&err );
if ( !thread ) {
FLUID_LOG( FLUID_ERR, "Failed to create the thread: %s",
fluid_gerror_message( err ) );
g_clear_error( &err );
}
return thread;
}
Regards,
Pedro