Author Topic: Is it safe to modify the wxSmith autogenerated command handler declarations ?  (Read 2456 times)

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Hello. In wxWidgets, it's recommended to not Skip() an event from a command handler from the point this command is supposed to be handled by one handler only. Also, when this handler does nothing with the passed event, the compiler (set to output extra warnings) raises this kind of warning :

Code: [Select]
warning: unused parameter 'event' [-Wunused-parameter]
So, I would like to use the WXUNUSED macro at call like this :

Code: [Select]
void OnQuit(wxCommandEvent& WXUNUSED(event));
Knowing this declaration is in a code part autogenerated by wxSmith, can I be sure it will not overwrite my modification ?

From my test, editing the menu item connected with this handler, it did not overwritten the declaration above, but I don't know the wxSmith internal and if it will not do it another time in another context... So, does the one(s) of you who maintain and continue the wxSmith development could confirm me (or not) that it's safe to modify this part of the autogenerated code (the part containing the prototypes in a header file) ?

Knowing, of course, I prefer to not move this line (and a lot of others in the same case) outside of the autogenerated part, since it would mean that I abandon wxSmith progressively :(
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline eranif

  • Regular
  • ***
  • Posts: 254
You can also use
Code: [Select]
wxUnusedVar(event)
in the function body to avoid this warning

Eran

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Nice :) Thanks a lot, eranif. I searched the doc and didn't seen this function, but it's effectivelly in defs.h with this comment :

Code: [Select]
/*  sometimes the value of a variable is *really* not used, to suppress  the */
/*  resulting warning you may pass it to this function */
#ifdef __cplusplus
#   ifdef __BORLANDC__
#       define wxUnusedVar(identifier) identifier
#   else
        template <class T>
            inline void wxUnusedVar(const T& WXUNUSED(t)) { }
#   endif
#endif

So, now I've the choice...

--
EDIT : I've finally used this solution everywhere it's needed because the WXUNUSED() macro in the handler prototypes masked them to wxSmith. I mean : wxSmith doesn't overwrite them but the concerned handlers don't appears anymore in the handlers listed in the properties grid (sounds like wxSmith search for the exact signature and not only the function name).
« Last Edit: August 12, 2013, 08:21:02 pm by eranon »
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]