Spirik / GEM

Good Enough Menu for Arduino
GNU Lesser General Public License v3.0
239 stars 36 forks source link

Fix compilation errors on ESP32 and ESP8266 #39

Closed 45gfg9 closed 2 years ago

45gfg9 commented 2 years ago

When compiling for ESP32, compiler emits errors for every GEMItem constructor for -Werror=reorder like this:

In file included from .pio/libdeps/dev/GEM/src/GEMPage.h:41:0,
                 from .pio/libdeps/dev/GEM/src/GEMItem.h:38,
                 from .pio/libdeps/dev/GEM/src/GEMItem.cpp:38:
.pio/libdeps/dev/GEM/src/GEMItem.h:160:24: error: 'GEMItem::readonly' will be initialized after [-Werror=reorder]
     boolean readonly = false;
                        ^
.pio/libdeps/dev/GEM/src/GEMItem.h:156:10: error:   'byte GEMItem::type' [-Werror=reorder]
     byte type;
          ^
.pio/libdeps/dev/GEM/src/GEMItem.cpp:253:1: error:   when initialized here [-Werror=reorder]
 GEMItem::GEMItem(char* title_, void (*buttonAction_)(), boolean readonly_)
 ^

When compiling for ESP8266, compiler emits error for getSelectedOptionNum not returning a value in all cases like this:

.pio/libdeps/8266/GEM/src/GEMSelect.cpp: In member function 'int GEMSelect::getSelectedOptionNum(void*)':
.pio/libdeps/8266/GEM/src/GEMSelect.cpp:107:1: error: control reaches end of non-void function [-Werror=return-type]
  107 | }
      | ^

This PR fixes these two problems, and I decided not to fix all the char * warnings...

Spirik commented 2 years ago

Good catch! Although I am not getting those exact warnings/errors (but do get a lot of char * ones) in Arduino IDE no matter what level of "Compiler warnings" I set up in Preferences (didn't try to compile in VS Code though). Do you use another dev environment with more restricted compiler settings?

45gfg9 commented 2 years ago

Oh, yes, I used VSCode + PlatformIO setup.

Spirik commented 2 years ago

Thank you for your PR! Updates will be shipped with the next release.

Spirik commented 2 years ago

@45gfg9 Just FYI, fixed char* related -Wwrite-strings warnings in recent 1.3.2 release.