rageworx / fltk-custom

A clone of FLTK 1.4.0 for enhance as customized GUI, more functional. This project is belong to https://fltk.org.
https://rageworx.info
Other
8 stars 1 forks source link

Compilaton warning at Fl_Shortcut_Button.cxx #65

Closed rageworx closed 1 year ago

rageworx commented 1 year ago

Warning occurs as

In file included from Fl_Shortcut_Button.cxx:17:
../FL/Fl_Shortcut_Button.H: In constructor 'Fl_Shortcut_Button::Fl_Shortcut_Butt
on(int, int, int, int, const char*)':
../FL/Fl_Shortcut_Button.H:28:15: warning: 'Fl_Shortcut_Button::shortcut_value'
will be initialized after [-Wreorder]
   28 |   Fl_Shortcut shortcut_value;
      |               ^~~~~~~~~~~~~~
../FL/Fl_Shortcut_Button.H:26:15: warning:   'Fl_Shortcut Fl_Shortcut_Button::de
fault_shortcut_' [-Wreorder]
   26 |   Fl_Shortcut default_shortcut_;
      |               ^~~~~~~~~~~~~~~~~
Fl_Shortcut_Button.cxx:45:1: warning:   when initialized here [-Wreorder]
   45 | Fl_Shortcut_Button::Fl_Shortcut_Button(int X,int Y,int W,int H, const ch
ar* l)
      | ^~~~~~~~~~~~~~~~~~

Is this warning still remians from fltk/fltk ? need to check.

rageworx commented 1 year ago

Difference between merged origin and dev,

+++ b/src/Fl_Shortcut_Button.cxx
@@ -49,8 +49,8 @@ Fl_Shortcut_Button::Fl_Shortcut_Button(int X,int Y,int W,int H, const char* l)
   default_set_(false),
   handle_default_button_(false),
   pre_esc_(0),
-  shortcut_value(0),
-  default_shortcut_(0)
+  default_shortcut_(0),
+  shortcut_value(0)
 {
   box(FL_DOWN_BOX);
   selection_color(FL_SELECTION_COLOR);
@@ -138,7 +138,7 @@ void Fl_Shortcut_Button::draw() {
     fl_draw(text, X, Y, W-H, H, align() | FL_ALIGN_INSIDE);
     fl_draw_symbol("@-29undo", X+W-H, Y, H, H, textcol);
   } else {
-  fl_draw(text, X, Y, W, H, align() | FL_ALIGN_INSIDE);
+    fl_draw(text, X, Y, W, H, align() | FL_ALIGN_INSIDE);
   }
   if (Fl::focus() == this) draw_focus();
 }
rageworx commented 1 year ago

It seems class initializing order default_shortcut_ is need to in order of previous shortcut_value .

rageworx commented 1 year ago

This compilation warning is fixed.