How to call virtual cpp function from main.c
Hi everyone.
There is a my page. I defined a virtual function there. And I changed the image's location. But I can not call this function from C. I research many example but can not arrive the success.
otherPageView.hpp
#ifndef OTHERPAGEVIEW_HPP
#define OTHERPAGEVIEW_HPP
#include <gui_generated/otherpage_screen/otherPageViewBase.hpp>
#include <gui/otherpage_screen/otherPagePresenter.hpp>
class otherPageView : public otherPageViewBase
{
public:
otherPageView();
virtual ~otherPageView() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void handleTickEvent();
virtual void function1();
protected:
};
#endif // OTHERPAGEVIEW_HPP
otherPageView.cpp
#include <gui/otherpage_screen/otherPageView.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include <math.h>
#include <touchgfx/hal/OSWrappers.hpp>
extern "C" void call_C_f(otherPageView* u) // wrapper function
{
return u->function1();
}
void otherPageView::function1()
{
image1.setXY(0, 50);
image1.invalidate();
}
otherPageView::otherPageView()
{
}
void otherPageView::setupScreen()
{
otherPageViewBase::setupScreen();
}
void otherPageView::tearDownScreen()
{
otherPageViewBase::tearDownScreen();
}
main.c
// I stayed in this point how to call like function1?
void call_C_f(struct C* o);
int main(void)
{
// bla, bla init...
while(1)
{
MX_TouchGFX_Process();
}
}
Thank you for your helps.
Best regards.
