Skip to content

Commit 5533426

Browse files
committed
PIO extra script to silence viotile warnings, cased by external libraries, after the upgrade to C++20
1 parent c4e2409 commit 5533426

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

config/nodemcu.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ build_src_filter = "+<arduino.cpp>"
8282
; https://docs.platformio.org/en/latest/projectconf/section_env_test.html#test-filter
8383
; todo: is it even possible to configure tests on NodeMcu?
8484
test_filter = embedded/*
85+
86+
; https://docs.platformio.org/en/latest/projectconf/sections/env/options/advanced/extra_scripts.html
87+
; https://docs.platformio.org/en/latest/scripting/actions.html
88+
extra_scripts = post:scripts/pio_post_extra_script.py

scripts/pio_post_extra_script.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Activate the script with `extra_scripts = pre:scripts/pio_post_extra_script.py` in `platformio.ini` config.
2+
#
3+
# https://docs.platformio.org/en/latest/projectconf/sections/env/options/advanced/extra_scripts.html
4+
# https://docs.platformio.org/en/latest/scripting/actions.html
5+
6+
Import("env")
7+
8+
# Silencing `volatile` warnings
9+
#
10+
# There is a lot "invalid" usages of `volatile` in the external libraries (dependencies):
11+
#
12+
# > .platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_i2s.cpp:179:23:
13+
# > warning: '++' expression of 'volatile'-qualified type is deprecated [-Wvolatile]
14+
#
15+
# The problem appears with the upgrade to C++20,
16+
# but they apparently de-deprecated it in C++23,
17+
# so there is little to no will to fix the usages:
18+
# https://github.com/esp8266/Arduino/issues/8916
19+
#
20+
# Therefore, I'm silencing `volatile`, so that the build keeps being clean,
21+
# and I don't miss any issues within _my_ code, hidden between the dependencies shitstorm.
22+
# Luckily, I don't use `volatile` myself, so _my_ code should not be at risk.
23+
#
24+
# todo: remove the the silencing, when GCC is upgraded, and I can use C++23 standard,
25+
# or if they fix the issues in the libs (not gonna happen ;p)
26+
#
27+
# I cannot set the flag with `build_flags`, because then it applies to both C++ and C,
28+
# while it is not valid for C -> and the warning appears:
29+
#
30+
# > cc1: warning: command-line option '-Wno-volatile' is valid for C++/ObjC++ but not for C
31+
#
32+
# Therefore, "hacking" with the `extra_scripts`:
33+
# * https://github.com/platformio/platformio-core/issues/1728
34+
# * https://github.com/platformio/platformio-core/issues/2144
35+
# * todo: get rid of `extra_scripts` when a "native to PIO" `build_flags` option can be properly set
36+
# * https://community.platformio.org/t/separate-settings-for-c-and-c-versions/21647
37+
# * https://community.platformio.org/t/silence-warnings-for-dependencies-external-libraries/33387
38+
#
39+
# Using `env` as it applies to everything, including the external libraries,
40+
# while `projectenv` would apply only to _my_ code,
41+
# https://github.com/platformio/platformio-core/issues/1728#issuecomment-403297776
42+
env.Append(CXXFLAGS=["-Wno-volatile"])

0 commit comments

Comments
 (0)