Open main menu

Difference between revisions of "Code Formatting Conventions"

→‎Preprocessor pragmas: -- added section
m (→‎Whitespaces: grammar)
(→‎Preprocessor pragmas: -- added section)
Line 184: Line 184:
</syntaxhighlight>
</syntaxhighlight>
* Note comment on whether fall through is intentional. Use exactly this and not some variation both for consistency and so that the compiler will see it and suppress potential warnings.
* Note comment on whether fall through is intentional. Use exactly this and not some variation both for consistency and so that the compiler will see it and suppress potential warnings.
== Preprocessor pragmas ==
All preprocessor pragrmas must start from the first column:
<syntaxhighlight lang="cpp">
#include "common/system.h"
#pragma mark --- Start of example ---
void example() {
    int i = 0;
#ifdef USE_FEATURE
    Feature f = new Feature();
#endif
    for (int x = 0; x < 10; x++) {
#define FOO f
        warning("%d", (FOO).code());
#undef FOO
    }
}
</syntaxhighlight>


== Naming ==
== Naming ==