Forums > Dev

calling other function, using return values

May 11, 2013 | 12:51 pm

is there an example in the sdk? i have this function : `void nocturn_init(t_nocturn *x)
{
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *dev;

usb_init();
usb_find_busses();
usb_find_devices();

busses = usb_get_busses();

for (bus = usb_get_busses(); bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if (dev->descriptor.idVendor == MY_VID
&& dev->descriptor.idProduct == MY_PID)
{
object_post((t_object *)x, "found a Novation Nocturn device");
object_post((t_object *)x, "Configurations : %i",dev->descriptor.bNumConfigurations);
return usb_open(dev);
}
}
}
return NULL;
} `

how do i call this from another function and use the returned value?


May 13, 2013 | 1:27 am

Hi there,

if you want to return a generic pointer, you need to define the function as:

void *nocturn_init(t_nocturn *x);

Otherwise if usb_open(dev) returns a specific type, you could use

that as the function return type;

 

To call it from another function:
void another_function(t_nocturn *x)
{
void *ret_ptr;
ret_ptr = nocturn_init(x);
}

Best.

- Luigi


May 13, 2013 | 8:59 am

thanks Luigi, i sorted that one out shortly after writing the thread, like so often..O.


Viewing 3 posts - 1 through 3 (of 3 total)