C++ Coding Guidelines: Difference between revisions

From LuxCoreRender Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Here are some guidelines for C++ Coding.
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 experts:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines


= Indentation =
= Indentation =
Indentation in LuxCore has historically used tabs rather than spaces.  Thank you for your compliance.
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.
Please avoid trailing spaces.
 
On a different note, please avoid trailing spaces.


= Boost =
= 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.).
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.
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.
 
Please systematically prefer C++20 standard library over Boost whenever possible and limit Boost to cases where there is no other solution.


= Raw pointers =
= 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.
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 =
= 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.
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.
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 <code> make doc </code>. After building, you'll find the documentation in <code> out/doc </code>.

Revision as of 17:34, 10 May 2025

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 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.

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 .