braydenanderson2014 / C-Arduino-Libraries

This repository contains C++ and Arduino Libraries that are lightweight and easy to use. All libraries were created/mimicked by me and chatgpt.
Apache License 2.0
13 stars 0 forks source link

Bug Report: Compilation Error with UnorderedMap in SimpleVector Library #77

Closed lucae98 closed 4 months ago

lucae98 commented 4 months ago

Bug Report: Compilation Error with UnorderedMap in SimpleVector Library

Summary: I am encountering compilation errors specifically related to the usage of UnorderedMap within the SimpleVector library. This prevents me from successfully compiling my Arduino project, where I intend to utilize UnorderedMap.

Description: When including the SimpleVector library (SimpleVector.h) in my Arduino project and attempting to use UnorderedMap, the compilation fails with errors related to template syntax and primary expressions. Specifically, the errors seem to be around the initialization and usage of UnorderedMap instances.

Steps to Reproduce:

Include SimpleVector.h and attempt to use UnorderedMap in an Arduino sketch.
Compile the sketch targeting an ESP32 board using PlatformIO.
Observe compilation errors related to template parameters and initialization of UnorderedMap.

Expected Behavior: The library should allow for the successful compilation and usage of UnorderedMap as described in its documentation, without encountering template syntax errors.

Actual Behavior: Compilation fails with errors indicating problems with template parameter handling and initialization of UnorderedMap, as detailed in the attached compiler output.

Environment:

PlatformIO IDE @ 3.3.3 PlatformIO @ 6.1.15 VSCode @ 1.90.0 Target Board: ESP32 (ESP32 Dev Module) Compiler: toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5 Unordered Map LibraryVersion: @ 1.0.4 SimpleVector Library Version: @ 1.0.7-BETA

Additional Information: I have ensured that all PlatformIO packages and dependencies are up-to-date. I reviewed the SimpleVector library documentation but did not find specific instructions addressing compatibility issues with UnorderedMap on the ESP32 platform or the mentioned compiler version.

Attachments:

Compiler output log highlighting the errors encountered during compilation.

I would appreciate your guidance or any updates regarding this issue with UnorderedMap. Please let me know if there are any workarounds or updates planned to address this compatibility issue.

Thank you for your attention to this matter.

Best regards,

Luca

Attachments:

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html PLATFORM: Espressif 32 (6.6.0) > Espressif ESP32 Dev Module HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:

framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
tool-esptoolpy @ 1.40501.0 (4.5.1)
toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- UnorderedMap @ 1.0.4
|-- Hashtable @ 1.1.2
|-- SimpleVector @ 1.0.7-BETA
Building in release mode
Compiling .pio/build/esp32dev/src/main.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Print.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/StreamString.cpp.o
In file included from .pio/libdeps/esp32dev/Hashtable/src/Hashtable.h:4,
from .pio/libdeps/esp32dev/UnorderedMap/src/UnorderedMap.h:4,
from src/main.cpp:2:
.pio/libdeps/esp32dev/SimpleVector/src/SimpleVector.h:76:34: error: expected ')' before '<' token
SimpleVector(initializer_list<T> initList) : array(new T[initList.size()]), count(initList.size()), capacity(initList.size()) {
~ ^
)
In file included from .pio/libdeps/esp32dev/Hashtable/src/Hashtable.h:4,
from .pio/libdeps/esp32dev/UnorderedMap/src/UnorderedMap.h:4,
from src/main.cpp:2:
.pio/libdeps/esp32dev/SimpleVector/src/SimpleVector.h: In member function 'T& SimpleVector<T>::get(unsigned int)':
.pio/libdeps/esp32dev/SimpleVector/src/SimpleVector.h:256:24: error: expected primary-expression before ';' token
return T()*; // You can handle this error differently if needed
^
*** [.pio/build/esp32dev/src/main.cpp.o] Error 1
braydenanderson2014 commented 4 months ago

Can you please send me a basic example of the code that's failing. How are you initializing the library objects. That will help me understand what's going on.

Thanks, -Brayden

lucae98 commented 4 months ago

include

include "UnorderedMap.h"

void setup() { Serial.begin(9600);

while (!Serial) { }

UnorderedMap<String, int> uMap;

uMap.put("TestValue", 545);

Serial.println(uMap.get("TestValue")); }

void loop() { }

braydenanderson2014 commented 4 months ago

Thank you very much. I will take a look at your issue tonight and see what I can figure out. I'll let you know what I find

braydenanderson2014 commented 4 months ago

So i am not sure about this error: .pio/libdeps/esp32dev/SimpleVector/src/SimpleVector.h:256:24: error: expected primary-expression before ';' token return T()*; // You can handle this error differently if needed... I was not able to recreate that issue.

BUT: I was able to solve the other issue: .pio/libdeps/esp32dev/SimpleVector/src/SimpleVector.h:76:34: error: expected ')' before '<' token SimpleVector(initializer_list initList) : array(new T[initList.size()]), count(initList.size()), capacity(initList.size()) { ~ ^ )

this issue had to do with your development platform (IE: Expressif/ ESP) ... the way i had coded some compiler directives basically forces you to utilize the initializer list functions that only show up for certain esp boards. I have modified the way the directives function. Now you would have to uncomment a directive for those functions to return. So by default the line is commented so you should no longer run into this issue. Platformio has been updated with the latest versions of Simple Vector and Hashtable.

Hierarchy: Unordered Map (DEPENDS ON->) Hashtable (DEPENDS ON->) SimpleVector [PROBLEM CHILD] (In this case)

Arduino Library and github will be updated shortly.

lucae98 commented 3 months ago

Thank You!

Luca