Skip to content

Cannot pass String variable into addControl argument #328

Open
@TheGreatPintoJ

Description

@TheGreatPintoJ

Describe the bug
When using ESPUI.addControl(Button, title, title, Alizarin, mainTab);
I get the error:

src/main.cpp:53:66: error: no matching function for call to 'ESPUIClass::addControl(ControlType, String&, String&, ControlColor, uint16_t&)'
ESPUI.addControl(Button, title, title, Alizarin, mainSelector);

To Reproduce
Steps to reproduce the behavior:

  1. In any working ESPUI sketch, try:
    String title = "New Option";
    ESPUI.addControl(Button, title, title, Alizarin, mainTab);
  2. Build or compile
  3. Observe error

Expected behavior
No error

Desktop (please complete the following information):

  • Windows 11
  • VSCode and PlatformIO
Full error Compiling .pio\build\seeed_xiao_esp32s3\src\main.cpp.o src/main.cpp: In function 'void addOption(Control*, int)': src/main.cpp:54:61: error: no matching function for call to 'ESPUIClass::addControl(ControlType, String&, String&, ControlColor, uint16_t&)' ESPUI.addControl(Button, title, title, Alizarin, mainTab); ^ In file included from src/main.cpp:3: .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:135:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*)' uint16_t addControl(ControlType type, const char* label); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:135:14: note: candidate expects 2 arguments, 5 provided .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:136:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&)' uint16_t addControl(ControlType type, const char* label, const String& value); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:136:14: note: candidate expects 3 arguments, 5 provided .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:137:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&, ControlColor)' uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:137:14: note: candidate expects 4 arguments, 5 provided .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:138:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&, ControlColor, uint16_t)' uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:138:14: note: no known conversion for argument 2 from 'String' to 'const char*' .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:139:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&, ControlColor, uint16_t, std::function)' uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, std::function callback); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:139:14: note: candidate expects 6 arguments, 5 provided .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:213:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&, ControlColor, uint16_t, std::function, void*)' uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, std::function callback, void* userData) ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:213:14: note: candidate expects 7 arguments, 5 provided .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:281:14: note: candidate: 'uint16_t ESPUIClass::addControl(ControlType, const char*, const String&, ControlColor, uint16_t, Control*)' uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, Control* control); ^~~~~~~~~~ .pio/libdeps/seeed_xiao_esp32s3/ESPUI/src/ESPUI.h:281:14: note: candidate expects 6 arguments, 5 provided *** [.pio\build\seeed_xiao_esp32s3\src\main.cpp.o] Error 1
(I don't know why its reformatting the error without newlines)

I should also mention I found a (hopefully temporary) workaround by using strdup(title.c_str())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions