C++ Coding Guidelines
Here are some guidelines for C++ Coding.
Modern C++
We ask you to enforce the best practices of "modern" C++ programming, as defined by best experts: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
True it is that legacy code may not always comply to those recommendations, but this is no reason for new code not to enforce them.
Indentation
Indentation in LuxCore has historically used tabs rather than spaces, so we will continue to observe this in the future, even if it may not be the most practical... Massive replacement of tabs by spaces may obfuscate history, so not recommended. Thank you for your compliance.
On a different note, please avoid trailing spaces.
Object naming
LuxCore uses camelCase/CamelCase style.
Local symbols are named with camelCase Global symbols are named with CamelCase.
Boost
Boost was used extensively in LuxCore, at a time when it was probably the only option for efficiently coding certain mechanisms (filepath, thread synchronization etc.).
Since v2.10, however, this is no longer the case, as LuxCore has been ported to C++20, which offers a standard library that can largely replace Boost, with a few exceptions.
Therefore please systematically prefer C++20 standard library over Boost whenever possible and limit Boost to cases where there is no other solution.
Raw pointers
LuxCore development was started before the advent of modern C++ (C++11 and higher) and logically conceals numerous raw pointers. However, raw pointers are quite risky, particularly in terms of memory leaks, dangling pointers, pointer aliasing etc., and should be avoided now, to the benefit of smart pointers.
Dependencies
Since version 2.10, a new dependency manager has been added ( LuxCoreDeps
). Other means to add dependencies are deprecated. In particular:
- do not embed external dependency source code
- do not use git submodules
- do not rely on precompiled binaries
Etc.
LuxCoreDeps
builds dependencies for sources, for all platforms, based on Conan database of build recipes.It guarantees reliability, portability and sustainability.
If you need to add a new dependency, please contact admin/dev team (on Discord, for instance, but also on Git or Forum).
Code Documentation
Please document your code: insert necessary information, comments etc., in the code in order for your peers to understand what you intend to do. "Your peers" encompass reviewers, other developers now and in the future etc.
LuxCore relies on Doxygen to generate code documentation: use Doxygen syntax to add the necessary information in your code.
Doxygen documentation can be built with make doc
. After building, you'll find the documentation in out/doc
.