Shadow warning in juce_Button.cpp

With last tip i get a warning now (Wshadow) on Ubuntu 20.04.3 LTS:

Compiling Main.cpp
Compiling BinaryData.cpp
Compiling include_juce_core.cpp
Compiling include_juce_data_structures.cpp
Compiling include_juce_events.cpp
Compiling include_juce_graphics.cpp
Compiling include_juce_gui_basics.cpp
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:147,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp: In constructor ‚Äėjuce::ButtonAccessibilityHandler::ButtonAccessibilityHandler(juce::Button&, juce::AccessibilityRole)‚Äô:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp:710:9: warning: declaration of ‚Äėrole‚Äô shadows a member of ‚Äėjuce::ButtonAccessibilityHandler‚Äô [-Wshadow]
  710 |         : AccessibilityHandler (buttonToWrap,
      |         ^
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.h:310,
                 from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:46,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.h:310:29: note: shadowed declaration is here
  310 |     const AccessibilityRole role;
      |                             ^~~~
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:147,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp: In constructor ‚Äėjuce::ButtonAccessibilityHandler::ButtonAccessibilityHandler(juce::Button&, juce::AccessibilityRole)‚Äô:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp:715:5: warning: declaration of ‚Äėrole‚Äô shadows a member of ‚Äėjuce::ButtonAccessibilityHandler‚Äô [-Wshadow]
  715 |     }
      |     ^
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.h:310,
                 from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:46,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.h:310:29: note: shadowed declaration is here
  310 |     const AccessibilityRole role;
      |                             ^~~~
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:147,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp: In constructor ‚Äėjuce::ButtonAccessibilityHandler::ButtonAccessibilityHandler(juce::Button&, juce::AccessibilityRole)‚Äô:
/home/jojo/JUCE/modules/juce_gui_basics/buttons/juce_Button.cpp:715:5: warning: declaration of ‚Äėrole‚Äô shadows a member of ‚Äėjuce::ButtonAccessibilityHandler‚Äô [-Wshadow]
  715 |     }
      |     ^
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.h:310,
                 from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:46,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.h:310:29: note: shadowed declaration is here
  310 |     const AccessibilityRole role;
      |                             ^~~~
Compiling include_spaghettis_core.cpp
Compiling include_spaghettis_gui.cpp
Linking Spaghettis - App

Edit: With default compiler (i guess it is gcc 9.3.0).
Edit: Works fine with clang++ on my RPI.

Thanks for reporting. We’ve fixed this on the develop branch and added the -Wshadow warning to our CI for GCC builds so should catch any warnings in the future.

1 Like