C++ Coding Guidelines

From LuxCoreRender Wiki
Revision as of 17:37, 10 May 2025 by Howetuft (talk | contribs) (Modern C++)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here are some guidelines for C++ Coding.

Modern C++

In general, we thank you for applying the best practices of "modern" C++ programming, as defined by best experts: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

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.

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.


Code Documentation

Please document your code: insert necessary information, comments etc., 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 .