EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1583 background imageLoading...
Page #1583 background image
Chapter 6. Contributions Guide
int res = do_something();
assert(res == 0);
Once the assert is optimized out, the res value is unused and the compiler will warn about this. However the
function do_something() must still be called, even if assertions are disabled.
When the variable is declared and initialized in a single statement, a good strategy is to cast it to void on a new line.
The compiler will not produce a warning, and the variable can still be optimized out of the final binary:
int res = do_something();
assert(res == 0);
(void)res;
If the variable is declared separately, for example if it is used for multiple assertions, then it can be declared with the
GCC attribute __attribute__((unused)). The compiler will not produce any unused variable warnings, but
the variable can still be optimized out:
int res __attribute__((unused));
res = do_something();
assert(res == 0);
res = do_something_else();
assert(res != 0);
Header file guards
All public facing header files should have preprocessor guards. A pragma is preferred:
#pragma once
over the following pattern:
#ifndef FILE_NAME_H
#define FILE_NAME_H
...
#endif // FILE_NAME_H
In addition to guard macros, all C header files should have extern "C" guards to allow the header to be used from
C++ code. Note that the following order should be used: pragma once, then any #include statements, then
extern "C" guards:
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* declarations go here */
#ifdef __cplusplus
}
#endif
Include statements
When writing #include statements, try to maintain the following order:
Espressif Systems 1572
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish