woboq / verdigris

Qt without moc: set of macros to use Qt without needing moc
https://woboq.com/blog/verdigris-qt-without-moc.html
GNU Lesser General Public License v3.0
638 stars 58 forks source link

Rename parameter to avoid compiler shadow warning. #100

Closed doctorseus closed 1 year ago

doctorseus commented 1 year ago

When compiling a project with gcc 11.3.0 and the latest version of verdigris it outputs

../../third_party/connectedhomeip/third_party/verdigris/repo/src/wobjectimpl.h: In constructor ‘constexpr w_internal::PropertyGenerator<State, T>::PropertyGenerator(State&)’:
../../third_party/connectedhomeip/third_party/verdigris/repo/src/wobjectimpl.h:352:40: warning: declaration of ‘s’ shadows a member of ‘w_internal::PropertyGenerator<State, T>’ [-Wshadow]
  352 |     constexpr PropertyGenerator(State& s) : s(s) {}
      |                                 ~~~~~~~^
../../third_party/connectedhomeip/third_party/verdigris/repo/src/wobjectimpl.h:351:12: note: shadowed declaration is here
  351 |     State& s;

when compiling with wobjectimpl.h. I renamed the constructor parameter for each occurrence to avoid the warning altogether.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

arBmind commented 1 year ago

Out of curiosity, what compiler flags do you use to get these warnings? We don't see them in clang or gcc builds or in the Github actions.

doctorseus commented 1 year ago

Out of curiosity, what compiler flags do you use to get these warnings? We don't see them in clang or gcc builds or in the Github actions.

The project is compiled with the -Wshadow flag which results in these warnings (I believe it exists for clang and gcc).

I also realized that there is an Interface class declaration which also results in a warning when the flag is enabled.