Skip to content

Commit 5b23aa3

Browse files
mcsprhasenradball
authored andcommitted
Add documentation entry about compiler warnings (esp8266#8492)
per esp8266#8421 and esp8266#8475 after checking HW, suggest to check SW as well by at least by enabling some or all compiler warnings (and also note of the IDE weirdest defaults causing issues we expected to stay solved)
1 parent 82472d8 commit 5b23aa3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

doc/faq/a02-my-esp-crashes.rst

+38
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ My ESP crashes running some code. How to troubleshoot it?
66
- `Introduction <#introduction>`__
77
- `What ESP has to Say <#what-esp-has-to-say>`__
88
- `Get Your H/W Right <#get-your-hw-right>`__
9+
- `Enable compilation warnings <#enable-compilation-warnings>`__
910
- `What is the Cause of Restart? <#what-is-the-cause-of-restart>`__
1011
- `Exception <#exception>`__
1112
- `Watchdog <#watchdog>`__
@@ -73,6 +74,43 @@ In any case, make sure that your module is able to stably run standard
7374
example sketches that establish Wi-Fi connection like, e.g.,
7475
`HelloServer.ino <https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer/examples/HelloServer>`__.
7576

77+
Enable compilation warnings
78+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
79+
80+
Most common issues may be resolved by enabling compilation warnings and fixing them.
81+
82+
For Arduino IDE, select ``File -> Preferences``:
83+
84+
- Make sure ``Show verbose output during: compilation`` is enabled
85+
- Set ``Compiler warnings`` to ``More`` or ``All``
86+
87+
For PlatformIO, all warnings should already be enabled by default.
88+
89+
Notice that the default configuration of Arduino IDE inhibits **all** compilation warnings.
90+
For the ESP8266 platform, some warnings should be treated as errors, otherwise it may cause unexpected issues at runtime:
91+
92+
.. code:: cpp
93+
94+
int func() {
95+
}
96+
97+
int other() {
98+
return func();
99+
}
100+
101+
Should fail to build with the following message:
102+
103+
.. code:: console
104+
105+
return-value.cpp: In function ‘int func()’:
106+
return-value.cpp:2:1: error: no return statement in function returning non-void [-Werror=return-type]
107+
2 | }
108+
| ^
109+
compilation terminated due to -Wfatal-errors.
110+
cc1plus: some warnings being treated as errors
111+
112+
Notice that ``-Werror=return-type`` is the default starting with Core 3.0.2 w/ GCC 10.3
113+
76114
What is the Cause of Restart?
77115
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78116

0 commit comments

Comments
 (0)