Chapter 6. Contributions Guide
• C standard library headers.
• Other POSIX standard headers and common extensions to them (such as sys/queue.h.)
• Common IDF headers (esp_log.h, esp_system.h, esp_timer.h, esp_sleep.h, etc.)
• Headers of other components, such as FreeRTOS.
• Public headers of the current component.
• Private headers.
Use angle brackets for C standard library headers and other POSIX headers (#include <stdio.h>).
Use double quotes for all other headers (#include "esp_log.h").
C++ Code Formatting
The same rules as for C apply. Where they are not enough, apply the following rules.
File Naming C++ Header files have the extension .hpp. C++ source files have the extension .cpp. The latter is
important for the compiler to distinguish them from normal C source files.
Naming
• Class and struct names shall be written in CamelCase with a capital letter as beginning. Member variables
and methods shall be in snake_case.
• Namespaces shall be in lower snake_case.
• Templates are specified in the line above the function declaration.
• Interfaces in terms of Object-Oriented Programming shall be named without the suffix ...Interface.
Later, this makes it easier to extract interfaces from normal classes and vice versa without making a breaking
change.
Member Order in Classes In order of precedence:
• First put the public members, then the protected, then private ones. Omit public, protected or private sections
without any members.
• First put constructors/destructors, then member functions, then member variables.
For example:
class ForExample {
public:
// first constructors, then default constructor, then destructor
ForExample(double example_factor_arg);
ForExample();
~ForExample();
// then remaining pubic methods
set_example_factor(double example_factor_arg);
// then public member variables
uint32_t public_data_member;
private:
// first private methods
void internal_method();
// then private member variables
double example_factor;
};
Espressif Systems 1573
Submit Document Feedback
Release v4.4