I have the code as below:
typedef struct widgest_s{
int WidgetId;
void *ItsPage;
}widget;
typedef widget Array_Type_Widget[3];
typedef struct Page_Type_s{
bool PageActive;
Array_Type_Widget Widgetlist;
Array_PageKeyTable PageKeys;
}Page_Type;
void init_main_page(const Page_Type* page)
{
Page_Type* loc = page;
update_pagewidget(&loc, &MainPageWidget);
}
void update_pagewidget( void *page, WidgetPtr Ptr)
{
Page_Type* loc_page = (Page_Type*)page;
for (int i = 0; i<3; i++)
{
(*loc_page->Widgetlist)[i] = Ptr(i);
}
}
I am trying to access the array of widgetlist. Ptr is callback function which returns the type widget. so while trying the access the widget array, i am Getting the error on line "(*loc_page->Widgetlist)[i] = Ptr(i)"
In this expression
*loc_page->Widgetlist
the array designator Widgetlist
is converted to a pointer to its first element. So dereferencing the pointer you get an object of the type widget
that is not an array. So you may not apply the subscript operator to the object.
It seems you mean
loc_page->Widgetlist[i] = Ptr(i);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.