letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.28k stars 2.21k forks source link

Build error with custom_274_ESP8266_4M1M #5150

Closed BasvanH closed 1 hour ago

BasvanH commented 2 hours ago

Describe the bug Building custom_274_ESP8266_4M1M without enabling any plugins goes as expected. When enabling one plugin I get this error during build:

src\src\Commands_tmp\__tmpfile.cpp:69449:69: error: size of array 'Plugin_id_to_DeviceIndex' is too large
Compiling .pio\build\custom_274_ESP8266_4M1M\FrameworkArduino\FunctionalInterrupt.cpp.o
 deviceIndex_t Plugin_id_to_DeviceIndex[Plugin_id_to_DeviceIndex_size]{};
                                                                     ^
src\src\Commands_tmp\__tmpfile.cpp: In function 'deviceIndex_t getDeviceIndex_from_PluginID(pluginID_t)':
src\src\Commands_tmp\__tmpfile.cpp:69517:14: error: 'Plugin_id_to_DeviceIndex' was not declared in this scope
       return Plugin_id_to_DeviceIndex[arrayIndex];
              ^
src\src\Commands_tmp\__tmpfile.cpp: In function 'void PluginSetup()':
src\src\Commands_tmp\__tmpfile.cpp:69568:5: error: 'Plugin_id_to_DeviceIndex' was not declared in this scope
     Plugin_id_to_DeviceIndex[id] = INVALID_DEVICE_INDEX;
     ^
src\src\Commands_tmp\__tmpfile.cpp:69584:9: error: 'Plugin_id_to_DeviceIndex' was not declared in this scope
         Plugin_id_to_DeviceIndex[arrayIndex] = deviceIndex;
         ^

To Reproduce 1) Create a Custom.h from the template 2) Enable one of the plugins 3) Build with custom_274_ESP8266_4M1M

Expected behavior No build errors

Used platform (please complete the following information):

Platform Specifics (when applicable, please complete the following information):

Additional context Did full and partial clean, did not help.

With custom_312_ESP8266_4M1M the error is also there but a bit different:

src\src\Commands_tmp\__tmpfile.cpp: At global scope:
src\src\Commands_tmp\__tmpfile.cpp:69449:40: error: size '4294967147' of array 'Plugin_id_to_DeviceIndex' exceeds maximum object size '2147483647'
69449 | deviceIndex_t Plugin_id_to_DeviceIndex[Plugin_id_to_DeviceIndex_size]{};
TD-er commented 2 hours ago

And just to be sure there's nothing else wrong, can you try with 2 plugins included?

TD-er commented 2 hours ago

Ah found the bug...

In _Plugin_init.cpp line 2105:

constexpr size_t Highest_Plugin_id = DeviceIndex_to_Plugin_id_size > 1 ? DeviceIndex_to_Plugin_id[DeviceIndex_to_Plugin_id_size - 1] : 0;

Should be:

constexpr size_t Highest_Plugin_id = DeviceIndex_to_Plugin_id_size > 0 ? DeviceIndex_to_Plugin_id[DeviceIndex_to_Plugin_id_size - 1] : 0;

Not yet tested... but it looks just like a typical 1-off error :)

BasvanH commented 2 hours ago

I only tested with 0 and 1 plugin enabled. Just enabled two, and this builds successfully.

#define USES_P001   // Switch
#define USES_P002   // ADC
BasvanH commented 1 hour ago
constexpr size_t Highest_Plugin_id = DeviceIndex_to_Plugin_id_size > 0 ? DeviceIndex_to_Plugin_id[DeviceIndex_to_Plugin_id_size - 1] : 0;

Applied this and indeed fixes it.

Thanks for the fast response and fix!

TD-er commented 1 hour ago

Great! Will merge it :)

Thanks for reporting it.