-
Notifications
You must be signed in to change notification settings - Fork 225
Coding Guide Lines
Axel Huebl edited this page Jan 12, 2016
·
45 revisions
You are here: Home > Developer Documentation > Coding Guide Lines
Help improving these guide lines!
- Add file name conventions (
camelCase, no_, small/big, ...) - Add something template meta programming specifig: public typedefs like
ValueTypeandtype(boost resultOf)-
ValueTypeis a public typedef for internal storage types (e.g. a single element of a field) - type traits should either define a
::resultor::type(the literature is not very unified in that) - what is necessary for a
resultOf(Rene?) - other common type defs in PIConGPU: borders/margins
-
- doxygen:
\cmdor@cmdstyle?/** ... */style (not//or/*!)
- use spaces around assignment operators, e.g.,
a = b / c; -
no TABS, use 4 spaces per level
- a new
namespacedoes not get spaces in front since we sometimes nest them 4 to 5 times:
- a new
namespace Clair
{
namespace Bob /* no spaces */
{
namespace Alice /* no spaces */
{
/* this guy gets intended */
Struct FooMe;
} // namespace Alice
} // namespace Bob
} // namespace Clair- Macros are written
ALL_UPPERCASEand can use_ - Align nested pre-compiler commands
#if(VARIABLE_BOB==1)
# if(VARIABLE_ALICE==1)
# define HPC +1
# endif
#endif- Macros with newlines: align
\symbol to column 80 - Describe how PreProcessor Macros are unrolled (excellent example)
/* < typename T0, ... , typename TN > */
template<BOOST_PP_ENUM_PARAMS(N, typename T)>
/* ( const T0, ... , const TN ) */
HDINLINE void operator()( BOOST_PP_ENUM_PARAMS(N, const T)) const-
TypeNamesandobjectInstances, e.g. definition ofEventTask myEventObject; - use CamelCaseNames instead of in-name
_if not explicitly stated otherwise (e.g. fixed pre-/suffixes) - References and Pointers are part of the Type (no space), e.g.
foo( int* i, float& b )
- omit curly braces for one-liners
if( a == b )
myFunction( c );
somethingElse();- braces on new lines (Yeah, East Coast Style!)
if( a == b )
{
/* do something */
}-
( ... )are part of the caller (see above), no space to that caller but spaces to arguments inside - same for template arguments:
template< ... > - object members are pre-fixed with an
m_(allows to fulfil-Wshadowin constructors, see below)
class A
{
private:
int m_myInt;
public:
A( int myInt ) : m_myInt( myInt )
{
/* ... */
}
};- Template Arguments shall be prefixed with
T_followed by upper case letter camel case for types (class, struct and native C types):
template<typename T_ValueType, class T_SomeOption>
class XYZ;- Template Arguments shall be prefixed with
T_followed by lower case letter camel case for values:
template<size_t T_size, bool T_isValid>
class XYZ;- function types and members can become quite long, use newlines:
template<class T_A> /* templates */
HDINLINE void /* compiler hints [optional newline] return type */
functionName( ... ) /* name params */
{
/* ... */
}or in a real-world example
/** brief description
*
* long description
*
* \tparam T_A is our first template parameter
* \param a is our first parameter
* \param b is our second parameter
*/
template<class T_A>
HDINLINE void
functionName( int a,
double b )
{
/* ... */
}- Copyright notice:
- each file must contain the corresponding (L)GPL header, Author(s) + current year (if changed - and a commit of a file means a change)
- you never remove an author or a year, you only add to them
- the following tool will add the header for you
- prefer explicit
/* ... */style - use Doxygen syntax for function/class description, choose the style
/** \doxygenVariable ... */ - you should avoid inline comments at all but you must not use
...; // commentas an inline comment - close namespaces with a comment:
} // namespace itsName
this section will be moved somewhere else!
-
master->tags:alpha,beta,1.0 -
dev->release-...->master(tagged commit) topic-myNewFeaturefix-aHotfixName
- vera++ (supports transformations -> auto-create pull request to pull request branch with proposed changes?)
- uncrustify
- cppcheck
- clang-format
- flint, flint++
- cpplint
- nsiqcppstyle
- KWStyle
All wiki entries describe the dev branch. Features may be different in the current master branch.
Before you start please read our README!
PIConGPU is a scientific project. If you present and/or publish scientific results that used PIConGPU, you should set a reference to show your support. Our according up-to-date publication at the time of your publication should be inquired from:
The documentation in this wiki is still not complete and we need your help keeping it up to date. Feel free to help improving this wiki!