Code Style
Style we actually try to follow in JuPedSim
The code is formated using the automatic formatter astyle with the option --style=stroustrup
Stroustrup style formatting/indenting uses stroustrup brackets. Brackets are broken from function definitions only. Brackets are attached to everything else including namespaces, classes, and statements within a function, arrays, structs, and enums. This style frequently is used with an indent of 5 spaces.
Here is an example:
int Foo(bool isBar)
{
if (isBar) {
bar();
return 1;
} else
return 0;
}
Tabs vs Spaces
this can be a long and religious discussion, to make it short DO NOT use tabs. Just spaces.
Editors
Here some hints to configure your editor in order to use the stroustrup style
Emacs
Add this to you .emacs
(setq c-default-style "stroustrup" c-basic-offset 5)
(setq indent-tabs-mode nil)
Eclipse
- Here is a plugin for astyle in eclipse.
- How to change indentation width in eclipse?
Vim
Set in your config file these variables
:set autoindent
:set cindent
:set expandtab
:set shiftwidth=5
:set softtabstop=5
Comments
- Comments and commit messages have to be written in english.