Re: Any suggestion please how to transfer a struct as user data ?
"Nick MacDonald" <[email protected]>
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
Start with this, quickly typed by hand and not compiled, but should work:
struct mydata
{
unsigned int type; /* If you think you might need more than one
type of structure */
unsigned int a;
unsigned int b; /* or whatever */
};
typedef stuct mydata *ptr2mydata;
/* global instance */
struct mydata myglobaldata;
main()
{
void* userDataPtr = &myglobaldata;
someExpatFunction(..., userDataPtr);
}
someExpatCallback(..., passes in userData,...)
{
ptr2mydata myuserdata=(ptr2mydata)userData; /* a cast */
printf("In function %s, userData->a=%u\n", __FUNCTION__, myuserdata->a);
/* and so on */
}
Good luck...