Note:
This applies to libopenmpt/
and openmpt123/
directories only.
Use OpenMPT style otherwise.
The code generally tries to follow these conventions, but they are not strictly enforced and there are valid reasons to diverge from these conventions. Using common sense is recommended.
std::size_t
and std::int32_t
over long
or int
. Do not use C99 std types (e.g. no pure int32_t
)using
.
Members of namespace openmpt
can be named without full namespace
qualification.namespace std
if the same functionality is
provided by the C standard library as well. Also, include the C++
version of C standard library headers (e.g. use <cstdio>
instead of
<stdio.h>
.std::locale::classic()
locale.{
are placed at the end of the opening line.if
.:
and ,
when inheriting or initializing members in a
constructor.*
is separated from both the type and the variable name.namespace openmpt {
// This is totally meaningless code and just illustrates indentation.
class foo
: public base
, public otherbase
{
private:
std::int32_t x;
std::int16_t y;
public:
foo()
: x(0)
, y(-1)
{
return;
}
int bar() const;
}; // class foo
int foo::bar() const {
for ( int i = 0; i < 23; ++i ) {
switch ( x ) {
case 2:
something( y );
break;
default:
something( ( y - 1 ) * 2 );
break;
}
}
if ( x == 12 ) {
return -1;
} else if ( x == 42 ) {
return 1;
}
return 42;
}
} // namespace openmpt