C++ Coding Guidelines

From LuxCoreRender Wiki
Revision as of 14:36, 10 May 2025 by Howetuft (talk | contribs)
Jump to navigation Jump to search

Here are some guidelines for C++ Coding.

Indentation

Indentation in LuxCore has historically used tabs rather than spaces. Thank you for your compliance. 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. Please use C++20 standard library instead of Boost whenever possible.

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.

Modern C++

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

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 uses Doxygen to generate code documentation. Use Doxygen syntax to add the necessary information to your code.