Skip to content

Coding Style and C Language Features

Allen A. Babb edited this page Sep 12, 2021 · 1 revision

A coding style or formatting style generally refers to the organization, placement, and tab and brace formatting practices. That is, things that have no impact on the logical interpretation of the code and is only visual. You can get a more in-depth definition on wikipedia

Currently there is no universal coding style enforced across the FSO codebase, but we do recommend that if you make changes in an existing file the existing style should be kept.

Usage of C++ features

We currently have a minimum target of VS 2015 so the used C++ features should be available in that version. At the moment we have no hard limits on what GCC or clang version needs to be supported though.

This means that all of C++11 and a decent amount of C++14 can be used.

Specific language features

RTTI and dynamic_cast

RTTI may be used to dynamically query the type of an object at runtime

nullptr

All new code should use a comparison with nullptr instead of NULL (or treating the pointer as a boolean); in other words, if (ptr != nullptr) is preferred to if (ptr != NULL) or if (ptr).