Structs Within Structs?
BlitzMax Forums/BlitzMax Programming/Structs Within Structs?
| ||
I've got the hang of receiving Structs from a DLL, I think, but the more advanced Structs have Structs within them. Now I'm not entirely sure how to handle these. Here's how they're defined ( Example ) typedef struct CAR { /* general module information */ CHAR* name; /* name of the car */ CHAR* mfrname; /* name of mfr */ UWORD flags; /* Car Info */ UWORD numwheels; /* number of wheels */ struct WHEEL* wheels; /* all wheels */ Exactly what should I expect to find where? I get as far as numwheels in my static bank containing the car struct, and then I'm not sure what I can expect. Am I expecting to find a series of wheel structs in this block of memory? Am I expecting to find a pointer to a series of wheel structs? Am I expecting to find a pointer to an array of pointers to individual wheel structs? All I do know is that the first int after the number of wheels comes back zero, which I find odd, so is there some kind of header? Like I say, really not sure what I'm seeing here. |
| ||
wheels will be a pointer to a block of memory numwheels*sizeof(WHEEL) bytes big (or as you call it a series). Given your zero result, you are treating UWORD as shorts which is giving you a correct sounding numwheels yes? |
| ||
Thanks, I thought that's what it would be, but it wasn't working. Now that I know my theory is right, I'll go back over the code for errors. Yes, I'm treating UWORDS as shorts, and I have verified that the number of wheels is correct. |