April 25, 2024, 12:36:11 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


C++ translation question

Started by J B Wood (Zumwalt), September 20, 2006, 10:36:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)


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?

Ionic Wind Support Team

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.

Ionic Wind Support Team

kryton9

a pointer to a pointer, like pointers weren't tough enough :)

How would you dereference twice?

J B Wood (Zumwalt)

Drink a flaming monkey, pray to the toilet.
flush

kryton9

he he he he, that is really funny Z  !!!

J B Wood (Zumwalt)

 ;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.

Ionic Wind Support Team

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];

Ionic Wind Support Team

kryton9

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(){}

Ionic Wind Support Team

?

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. 

Ionic Wind Support Team

Parker

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.

kryton9

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!!

J B Wood (Zumwalt)

Thanks all. It helps.
I have some recoding to do.