Syntax problem with struct and pointers Topic is solved

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
dsteinwe
Experienced Member
Posts: 87
Joined: Wed Jun 29, 2016 8:59 am

Syntax problem with struct and pointers

Post by dsteinwe »

Hi,

I'm trying to use the interface "usb_ep0_callback_if" from the xmos usb lib. The function "get_interface_descriptor" of this interface has the weird parameter "const ep0_descriptor * unsafe &descs", I have no clue how to use. I am confused by using both operators together "*" and "&". "ep0_descriptor" is defined as:

Code: Select all

typedef struct ep0_descriptor {
  const char * unsafe desc;
  size_t len;
} ep0_descriptor;
I would expect, that I could use it like this:

Code: Select all

size_t my_len = 20;
unsafe {
	descs->desc = &my_array;
	desc->len = &my_len;
}
Unfortunately, it does not work. What is the right syntax? It would help me, if you explain the syntax.


View Solution
User avatar
mon2
XCore Legend
Posts: 1912
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Try

Code: Select all

size_t my_len = 20;
unsafe {
	descs->desc = &my_array;
	descs->len = my_len;
}
User avatar
dsteinwe
Experienced Member
Posts: 87
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

What a stupid mistake! Have focused all the time on the string but "len" was the problem. Thanks mon2.