Pointer to pointer array of scene nodes
Re: Pointer to pointer array of scene nodes
robmar I'm not sure why you don't just pass the name of the first member of the group as the pointer to the array.
Re: Pointer to pointer array of scene nodes
that´s of course what I did!!
Read my posts please everyone!!!
VS C++ DOES NOT ALLOW passing ptrs to ptr arrays of neither void nor abstract classes!!!!!
By just changing from an array of ILightSceneNode pointers to an array of vector3fd pointers, everything compiles.
But MY AIM HERE is to have an array of ILightSceneNode pointers, and pass a ptr of it!!! Which VC++ does not allow!!!
That is unless someone else can prove otherwise by actually doing it, compiling it, not just saying it!
Read my posts please everyone!!!
VS C++ DOES NOT ALLOW passing ptrs to ptr arrays of neither void nor abstract classes!!!!!
By just changing from an array of ILightSceneNode pointers to an array of vector3fd pointers, everything compiles.
But MY AIM HERE is to have an array of ILightSceneNode pointers, and pass a ptr of it!!! Which VC++ does not allow!!!
That is unless someone else can prove otherwise by actually doing it, compiling it, not just saying it!
Last edited by robmar on Tue Jan 08, 2013 5:39 pm, edited 1 time in total.
Re: Pointer to pointer array of scene nodes
robmar wrote: VS C++ DOES NOT ALLOW passing ptrs to ptr arrays of neither void nor abstract classes!!!!!
Working on game: Marrbles (Currently stopped).
Re: Pointer to pointer array of scene nodes
I must admit I just tried it for a few minutes and also couldn't figure out how to pass it correct. Polylux definition is correct for beeing an array full of pointers, so much is certain. Passing it by value would also be simple. But passing a pointer to that with the restriction of the size in the constant correctly... would need more time to figure that out it seems :-)
Maybe use some typedef - makes things often easier.
Maybe use some typedef - makes things often easier.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
Its a bit of a head-twister for sure.... and where is the logic in not allowing this:-
void *p1[8]; // Array of void pointers
void (*p2)[8]; // Single pointer to an array of void pointers
p2 = p1; // Not allowed, ptr to array of voids not legal!
The parenthesis is important to stop the 2nd declaration becoming another array of pointers
But this is legal:-
int *p1[8]; Array of int pointers
int (*p2)[8]; // Single pointer to an array of int pointers
p2 = p1; // Allowed, ptr to array of ints IS legal!
void *p1[8]; // Array of void pointers
void (*p2)[8]; // Single pointer to an array of void pointers
p2 = p1; // Not allowed, ptr to array of voids not legal!
The parenthesis is important to stop the 2nd declaration becoming another array of pointers
But this is legal:-
int *p1[8]; Array of int pointers
int (*p2)[8]; // Single pointer to an array of int pointers
p2 = p1; // Allowed, ptr to array of ints IS legal!
Re: Pointer to pointer array of scene nodes
void (*p2)[8]; is a pointer to an array of void - not to an array of void*.
Same in your second example - which also doesn't compile here by the way (gcc).
edit: And yes - it's a horrible syntax. Same problem in language design as everywhere in programming - if you don't get it right on the first time then you're stuck with it for eternity :-)
There are some rules how to read those declarations which you can find browsing around al little (something about going left-right-left-right all the time, but I must also look it up if I have such a structure once every few years).
Same in your second example - which also doesn't compile here by the way (gcc).
edit: And yes - it's a horrible syntax. Same problem in language design as everywhere in programming - if you don't get it right on the first time then you're stuck with it for eternity :-)
There are some rules how to read those declarations which you can find browsing around al little (something about going left-right-left-right all the time, but I must also look it up if I have such a structure once every few years).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
I knew I´d probably screw that up somewhere!
So...
void *(*p2)[8] // Pointer to an array of void pointers...
This is a pointer, type void, to an array of pointers...
or should that be:-
void (*p2)(*)[8] // Pointer to an array of void pointers
my mind goes blank sorta quickly with this syntax!
So...
void *(*p2)[8] // Pointer to an array of void pointers...
This is a pointer, type void, to an array of pointers...
or should that be:-
void (*p2)(*)[8] // Pointer to an array of void pointers
my mind goes blank sorta quickly with this syntax!
Re: Pointer to pointer array of scene nodes
Eh, chill with the arrays and just go full-pointers
void **p1; // pointer to an array of void *
void ***p2; // pointer to a pointer to an array of void *
void **p1; // pointer to an array of void *
void ***p2; // pointer to a pointer to an array of void *
Re: Pointer to pointer array of scene nodes
That sounds soooo easy! Did you try it by passing a ptr to an array of voids or even ILightSceneNode ptrs? ... maybe you should try it!
void *pLights[8];
void ***...
void *pLights[8];
void ***...
Re: Pointer to pointer array of scene nodes
what about what I posted before:
Code: Select all
#include <iostream>
class Abstract
{
public:
virtual void pureVirt() = 0;
};
void func(Abstract ** b);
int main()
{
Abstract * array[99];
func(array);
if(array[0]==NULL)
std::cout << "is NULL\n";
return 0;
}
void func(Abstract ** b)
{
b[0]=NULL;
}
Working on game: Marrbles (Currently stopped).
Re: Pointer to pointer array of scene nodes
serengeor: Yeah, passing that way is still easy. But what I couldn't figure out is the additional size restriction - so the function can only pass a pointer to an array of a certain size.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
Did you try to compile it?
The only person so far who did a real test, CuteAlien, also reported that it produced compiler errors.
The only person so far who did a real test, CuteAlien, also reported that it produced compiler errors.
Re: Pointer to pointer array of scene nodes
Uhm - I didn't test this one - that should work (on first view - didn't compile this). It's just passing a pointer to an array of pointers of undefined size. Which means you either have to set the last to 0 or pass the lenght or you won't know how many are in there. The difficulty I'm having is the size-constant you are using...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
what size constant? I think this all seems so simple, that is until you try it! Then you get Error! Void and abstract class ptr to ptrs not legal...