In C and in older C++ compilers, you could write code like this
void a(void** pp); // declare a function that takes a pointer to a pointer-to-void.
struct I {}; // some struct.
I *i1,**i2; // some kinds of i.
a(&i1); // this works
a(i2); // this also worked.
a(i1); // error: incorrect levels of indirection
a(&i2); // error: incorrect levels of indirection
Now, c++ compilers just don't like void* anymore. meaning we absolutely have to static cast to a void** because c++ compiler are too damn high and mighty to let a void** slip past on a mere levels of indirection check.
a((void**)&i1); // this works
a((void**)i2); // this also worked.
a((void**)i1); // oops
a((void**)&i2); // oops
Yay for c++ helping us avoid bugs.
indirection checking was useful damnit.
void a(void** pp); // declare a function that takes a pointer to a pointer-to-void.
struct I {}; // some struct.
I *i1,**i2; // some kinds of i.
a(&i1); // this works
a(i2); // this also worked.
a(i1); // error: incorrect levels of indirection
a(&i2); // error: incorrect levels of indirection
Now, c++ compilers just don't like void* anymore. meaning we absolutely have to static cast to a void** because c++ compiler are too damn high and mighty to let a void** slip past on a mere levels of indirection check.
a((void**)&i1); // this works
a((void**)i2); // this also worked.
a((void**)i1); // oops
a((void**)&i2); // oops
Yay for c++ helping us avoid bugs.
indirection checking was useful damnit.
Comment