Coding standards

Shachar Shemesh wine-devel at
Mon Nov 25 01:38:36 CST 2002

Due to Robert's question regarding coding standards, I would like to 
summarize the discussion from a while back. If someone wants to take 
this discussion and turn it into a HOWTO.....

These are, to the best of my memory, the conclusions. In the examples, 
\t means tab (it will be followed by a real tab), ^ means space:
1. Indentations - Hard tabs must be used for indicating indent level. 
That means that the function definition is at the begning of the line, 
first level is preceded by one tab, etc. If your convention is that 
continuation lines are a single indent deeper, use a tab for that as well.

\t	for( a=0; b<a;
\t	\t	a-- )
\t	{
\t	\t	do something;

2. Tabs should not used for anything other than indicating indent level, 
as that would create a dependancy on tab size. If your convention is 
that continuation lines are aligned with constructs from the previous 
line, use spaces to perform the alignments

\t	for( a=0; b<a;
\t	^^^^a-- )

3. Tab size should be around 3 characters. Some prefer 2, some prefer 4, 
but if the above guidlines are followed this should not change the 
correctness of rendering.
4. Open curly braces defining a function must come on the following line 
to the function definition:

int funct( void )
\t	...

5. Open curly braces defining an internal block may be either on the 
following line or at the end of the line triggering the brace:

\t	for( i=0; i<50; ++i )
\t	{
\t	\t	array[i]=17;
\t	}


\t	for( i=0; i<50; ++i ) {
\t	\t	array[i]=17;
\t	}

The most important of all the rules:
6. When changing code written by someone else, follow the existing 
convention with your new code.

Subjects still missing:
- Hungarian notaion - gift of god or a creation of evil?
- Non Win32 API functions - names, parameter names, types?


More information about the wine-devel mailing list