Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix -Wshadow warning for Interrupt callbacks #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
earlephilhower wants to merge 1 commit into arduino:master
base: master
Choose a base branch
Loading
from earlephilhower:patch-1

Conversation

Copy link
Contributor

@earlephilhower earlephilhower commented Sep 19, 2025
edited
Loading

Adding -Wshadow to builds identified a template for the Interrupt callback which used a local variable the same as the function parameter. Rename the local variable to not shadow the parameter and make GCC happier.

The GCC warning for -Wshadow is as follows:

In file included from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/ArduinoAPI.h:29,
 from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/ArduinoAPI.h:2,
 from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/Arduino.h:28,
 from /tmp/arduino_build_576215/sketch/DataLoggerUSB.ino.cpp:1:
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h: In lambda function:
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h:50:7: warning: declaration of 'T param' shadows a parameter [-Wshadow]
 50 | T param = *(T*)((struct __container__<T>*)a)->param;
 | ^~~~~
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h:40:125: note: shadowed declaration is here
 40 | template<typename T> void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam<T> userFunc, PinStatus mode, T& param) {
 | ~~~^~~~~

Adding -Wshadow to builds identified a template for the Interrupt
callback which used a local variable the same as the class variable.
Rename the local variable to not shadow the class one and make
GCC happier.
Copy link
Contributor Author

Unit tests looks like it's failing in some other part of the CI infra not related to the 2-line patch here

 /home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp: In function ‘void C_A_T_C_H_T_E_S_T_4()’:
 /home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp:45:7: error: moving ‘a’ of type ‘arduino::String’ to itself [-Werror=self-move]
 45 | a = std::move(a);
 | ~~^~~~~~~~~~~~~~
 /home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp:45:7: note: remove ‘std::move’ call
pennam reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /