int func(void**); { short* p = NULL; func(&p); //<<< here } Could somebody remind me why is this not allowed ? error message: "cannot convert parameter from 'short **' to 'void **'" Thanks, Igor
On 2005-11-22, Igor Okulist <igor@remove_this_okulist.com> wrote: > int func(void**); > > { > short* p = NULL; > func(&p); //<<< here > } > > Could somebody remind me why is this not allowed ? error > message: "cannot convert parameter from 'short **' to 'void > **'" You're attempting to automatically convert a pointer to pointer to short to a pointer to pointer to void. A pointer to pointer to void hasn't got the special semantics of a void pointer. -- Neil Cerutti
Igor Okulist wrote: > int func(void**); > > { > short* p = NULL; > func(&p); //<<< here > } > > Could somebody remind me why is this not allowed ? > error message: "cannot convert parameter from 'short **' to 'void **'" > Because while a short* value can be converted to a void*, it's not the case that they are the same format. short** and void** are therefore not convertible. Imagine that you have an architecture where a char* (and hence void*) are 32 bits byte addressed and a short pointer is word addressed. When you do short s; short* sp = &s; void* vp = sp; the compiler needs to shift the short value to the left to store it in the void pointer. However, if you were allowed to do this: void** vpp = &sp; How would the compiler know to convert the short* value?
> You're attempting to automatically convert a pointer to pointer > to short to a pointer to pointer to void. > > A pointer to pointer to void hasn't got the special semantics of > a void pointer. > > -- > Neil Cerutti Neil, Is there a reason why the semantics do not apply to void**? or just no body bothered to specify it? The stride will always be the same ( lets disregard the near/far possibility). Thanks, Igor
Igor Okulist wrote: > int func(void**); > > { > short* p = NULL; > func(&p); //<<< here > } > > Could somebody remind me why is this not allowed ? > http://www.parashift.com/c++-faq-lite/proper-inheritance.html#faq-21.2 ALthough it speaks to classes the same logic would apply.
Igor Okulist wrote: > int func(void**); > > { > short* p = NULL; > func(&p); //<<< here > } > > Could somebody remind me why is this not allowed ? > http://www.parashift.com/c++-faq-lite/proper-inheritance.html#faq-21.2 ALthough it speaks to classes the same logic would apply.