Click to See Complete Forum and Search --> : Weird void** ?
codegurugeek
July 8th, 2005, 12:12 AM
Guys,
i don't know what is the difference between "void**" and "void"??
I even look through the msdn webside with that keyword.. but couldn't get any result...
Can anyone explain to me ?
SouthernCodeMonkey
July 8th, 2005, 12:42 AM
See MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/key_s-z_9.asp
Regards.
codegurugeek
July 8th, 2005, 12:55 AM
alright.. base on the explanation from the msdn.. i understand that if
void --> for function usage;
void* --> universal pointer;
void** --> ?
is void ** = &(void*)??
SouthernCodeMonkey
July 8th, 2005, 01:04 AM
Yes, void** is ptr to void ptr.
NoHero
July 8th, 2005, 06:49 AM
void = Nothing. Not even for function declaration that do not return something...
// A function that has no arguments
int main ( void )
{
return 0;
}
You can even cast something to void:
// Cast to void, to tell the compiler to make an optimation for not checking and/or storing the return value
int main ( void )
{
(void)printf("Hello World\n");
return 0;
}
void* ... Is an universal pointer that does not need casting in C but so in C++.
void** ... A pointer to a pointer. (A string array for example). Since void is nothing special at all you cannot use the [] operators to declare an array of pointers. So void * narf[] is not allowed because it is of an unspecified type of size. But for example char* narf[] would be allowed because the size of char is specified. To avoid this problem you write void ** which would be the same as void *[] if it would be allowed.
codegurugeek
July 16th, 2005, 05:13 AM
Alright.. got it..
However, why isnt the one below working?
IGraphBuilder* igb;
IMediaControl* imc;
void* tempimc = imc;
temphr = igb->QueryInterface(IID_IMediaControl,&tempimc);
i am getting the annoying error
Stating that i "can't convert * __gc* to void**"
may i know what is the matter?
NoHero
July 16th, 2005, 07:02 AM
IGraphBuilder* igb;
IMediaControl* imc;
void* tempimc = imc;
temphr = igb->QueryInterface(IID_IMediaControl,&tempimc);
The compiler thinks those two pointers are managed pointers, but are in fact only unmanaged COM pointers. Use __nogc to mark non-managed pointers.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.