Skip to content

Commit

Permalink
Add documentation entry about compiler warnings (#8492)
Browse files Browse the repository at this point in the history
per #8421 and #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)
  • Loading branch information
mcspr committed Feb 22, 2022
1 parent 15e7d35 commit fd53a08
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/faq/a02-my-esp-crashes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ My ESP crashes running some code. How to troubleshoot it?
- `Introduction <#introduction>`__
- `What ESP has to Say <#what-esp-has-to-say>`__
- `Get Your H/W Right <#get-your-hw-right>`__
- `Enable compilation warnings <#enable-compilation-warnings>`__
- `What is the Cause of Restart? <#what-is-the-cause-of-restart>`__
- `Exception <#exception>`__
- `Watchdog <#watchdog>`__
Expand Down Expand Up @@ -73,6 +74,43 @@ In any case, make sure that your module is able to stably run standard
example sketches that establish Wi-Fi connection like, e.g.,
`HelloServer.ino <https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer/examples/HelloServer>`__.

Enable compilation warnings
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most common issues may be resolved by enabling compilation warnings and fixing them.

For Arduino IDE, select ``File -> Preferences``:

- Make sure ``Show verbose output during: compilation`` is enabled
- Set ``Compiler warnings`` to ``More`` or ``All``

For PlatformIO, all warnings should already be enabled by default.

Notice that the default configuration of Arduino IDE inhibits **all** compilation warnings.
For the ESP8266 platform, some warnings should be treated as errors, otherwise it may cause unexpected issues at runtime:

.. code:: cpp
int func() {
}
int other() {
return func();
}
Should fail to build with the following message:

.. code:: console
return-value.cpp: In function ‘int func()’:
return-value.cpp:2:1: error: no return statement in function returning non-void [-Werror=return-type]
2 | }
| ^
compilation terminated due to -Wfatal-errors.
cc1plus: some warnings being treated as errors
Notice that ``-Werror=return-type`` is the default starting with Core 3.0.2 w/ GCC 10.3

What is the Cause of Restart?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit fd53a08

Please sign in to comment.