Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed in PlarformIO #1

Open
redstonee opened this issue Mar 19, 2024 · 3 comments
Open

Build failed in PlarformIO #1

redstonee opened this issue Mar 19, 2024 · 3 comments

Comments

@redstonee
Copy link

Hello! I'm trying to use lvglpp in a Platform IO project. When I start building it, errors occurs like below:

lib/lvglpp/src/lvglpp/widgets/switch/switch.cpp:12:5: error: specializing member 'lvgl::core::Widget<lv_switch_create>::Switch' requires 'template<>' syntax
     Switch::Switch() {
     ^~~~~~
lib/lvglpp/src/lvglpp/widgets/switch/switch.cpp:16:5: error: specializing member 'lvgl::core::Widget<lv_switch_create>::Switch' requires 'template<>' syntax
     Switch::Switch(Object & parent) {
     ^~~~~~
lib/lvglpp/src/lvglpp/widgets/switch/switch.cpp:20:10: error: specializing member 'lvgl::core::Widget<lv_switch_create>::initialize' requires 'template<>' syntax
     void Switch::initialize() {
          ^~~~~~
lib/lvglpp/src/lvglpp/widgets/switch/switch.cpp:23:10: error: specializing member 'lvgl::core::Widget<lv_switch_create>::initialize' requires 'template<>' syntax
     void Switch::initialize(Object & parent) {
          ^~~~~~
*** [.pio\build\esp32-s3-devkitc-1\libee7\lvglpp\lvglpp\widgets\switch\switch.cpp.o] Error 1

The platform is esp32-s3, and the C++ standard is set to gnu++2a.
Thank you!

@vpaeder
Copy link
Owner

vpaeder commented Mar 23, 2024

Hi!
I guess clang is less restrictive there as I doesn't complain. The Switch class is a specialization of the Widget class. Try to add ´template<>´ in front of the offending lines and see what happens. If that doesn't fix it I'll see to write it by the standards, but that might take some time.

@redstonee
Copy link
Author

Thanks very much for your reply!
I tried to rewrite the Switch class with a more complicated way as below:

class Switch : public Widget<lv_switch_create> {
    void initialize();
    void initialize(Object &parent);

  public:
    using Widget::Widget;
};

And removed the constructors in switch.cpp then it works.
Besides, there are some dynamic_pointer_cast in anim.cpp, which requires RTTI feature. However if -fno-rtti is removed when building the project for ESP32, linking errors occured. Then I replaced them with static_pointer_cast, which made it able to build. But when an animation is configured, my ESP32 crashed with this info:

assert failed: void lvgl::misc::Animation::set_path_cb(lv_anim_path_cb_t) anim.cpp:60 (this != this->raw_ptr()->var)

Now I have no idea how to fix it. :(

@vpaeder
Copy link
Owner

vpaeder commented Apr 21, 2024

Well, you're just subclassing a template class, which is fine but this shouldn't be necessary.
For the dynamic cast thing, I can't say if I don't know what the linking errors are. With static cast you're removing a runtime check, but if you know how to keep your code safe that way go ahead.
The assert fails when you used Animation.set_var or any of the callback setters in template form and you try to use one callback setter in non-template form. You would replace the pointer to the callbacks stored in the C structure and make some previously-defined callbacks to fail. Post the bit of code where you define the animation object and callbacks and we can see what should be amended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants