I usually use 2 spaces for indentation everywhere in my projects.
The brackets of a function, I usually lay out like this:
```
/**
* Short parameter list
*/
int myfunction(int a, int b){
code;
}
/**
* Long parameter list
*/
int myfunction(
int parameter1,
int parameter2,
int parameter3,
int parameter4
){
code;
}
```
Also, I use if(){} and while(){} instead of if () {} and while () {}. I may put some spaces inside the (), though. I also sometimes put the conditions on multiple lines
```
if( (a == b || c ==1)
&& x == y
&& condition3
){}
```
For single statements, I sometimes omit the {}. For if statements, I only do that if there is no else branch.
```
if(condition)
break;
if( condition1
&& condition2
) break;
```
Although, for the second example, I only ever do that with break; or return;, but not for other / longer statements, those I do usually put in brackets.
I like to use braces in switch case statements:
```
switch(x){
case ENUM_CONSTANT_A: {
code;
} break;
case ENUM_CONSTANT_B: {
code;
} break;
}
```
This is great for limiting the scope of local variables in those blocks.
On rare Occasions, I may also put them inside the braces. For example:
```
switch(x){
{ break; case ENUM_CONSTANT_A:;
code;
}
{ break; case ENUM_CONSTANT_B:;
code;
}
}
```
This can be useful when generating code sometimes.
Regards,
Daniel Abrecht