IonicWind Software

Aurora Compiler => General Discussion => Topic started by: J B Wood (Zumwalt) on September 20, 2006, 10:36:43 AM

Title: C++ translation question
Post by: J B Wood (Zumwalt) on September 20, 2006, 10:36:43 AM

WIN32DLL_API void CALLMODE_API iMeshVertexBufferOpen(MESH*,MESHVERTEX**);


I get and understand MESH* this is a UINT, but, MESHVERTEX is a structure, so that said, what is the ** for?
How do I translate that?
Title: Re: C++ translation question
Post by: Ionic Wind Support Team on September 20, 2006, 10:43:55 AM
That is C's method of stating a 'pointer to a pointer to a MESHVERTEX structure'.  probably returns a pointer to allocated memory as an array.

Just declare it as MESHVERTEX* in Aurora and give it a pointer.  You will need to dereference twice to get at the data.

Paul.

Title: Re: C++ translation question
Post by: kryton9 on September 20, 2006, 12:37:17 PM
a pointer to a pointer, like pointers weren't tough enough :)

How would you dereference twice?
Title: Re: C++ translation question
Post by: J B Wood (Zumwalt) on September 20, 2006, 02:09:27 PM
Drink a flaming monkey, pray to the toilet.
flush
Title: Re: C++ translation question
Post by: kryton9 on September 20, 2006, 02:12:06 PM
he he he he, that is really funny Z  !!!
Title: Re: C++ translation question
Post by: J B Wood (Zumwalt) on September 20, 2006, 02:15:57 PM
 ;D I couldn't help myself.
Anyway, what I am trying to do at this time is turing out to not be feasable since it won't work in the other language I was attempting it in.
Luckly Aurora supports pointers otherwise it would be a waste here to.
I was attempting to figure it out for vb.net also, and since it is only returning the first element of the array instead of the entire 1002 set, I am buggered.
Title: Re: C++ translation question
Post by: Ionic Wind Support Team on September 20, 2006, 05:44:00 PM
You dereference twice.

*(MESHVERTEX)*(POINTER)variable

However if they are using a C style array then you could probably just send it a pointer and use:

*(MESHVERTEX)variable[index];

Title: Re: C++ translation question
Post by: kryton9 on September 20, 2006, 06:54:11 PM
I think this is the key to the program that writes itself.

*(thought)headaches->Needs.ToGet(finished).**->AhHah??|computer.Compute|::OnClose()

Oh, I forgot the braces:

*(thought)headaches->Needs.ToGet(finished).**->AhHah??|computer.Compute|::OnClose(){}
Title: Re: C++ translation question
Post by: Ionic Wind Support Team on September 20, 2006, 07:16:04 PM
?

I wasn't being funny, just answering his question. 

Multiple derferencing is common in C and C++, which is why you need to understand it if you're going to use DLL's, toolkits, physics libraries,etc that make use of C arrays. 

Title: Re: C++ translation question
Post by: Parker on September 20, 2006, 08:02:00 PM
int main( int argc, char **argv )
{
    //...
}

From your first C program you're using multiple level pointers. That's because in C an array is a pointer, and they even let you write char *argv[] instead if you want. When you use the [] operator in C, it is the same thing as *(array + index * sizeof( array ) ). In this case, argv is an array of strings, and since a string is an array of characters, it's an array of arrays of characters.

Sorry if that's confusing, but that's the way it works.
Title: Re: C++ translation question
Post by: kryton9 on September 20, 2006, 08:37:04 PM
I didn't mean anything by what I wrote, just having fun... to me it looks like that and feels like that a times. Didn't mean anything else more by it other than that.

Appreciate the help as always and explanations!!
Title: Re: C++ translation question
Post by: J B Wood (Zumwalt) on September 20, 2006, 08:52:44 PM
Thanks all. It helps.
I have some recoding to do.