View Single Post
Old Nov 11th, 2007, 11:03 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Incompatible pointer type (double pointer in a function)

The standard requires that the compiler have a means of converting the name of an array into a pointer to that array. Now, the question is, is that a pointer or a double pointer or a triple pointer? You could coerce that with a cast, and the compiler would accept that you knew what you were doing.

Obviously, though, you don't. If you consider a contiguous array of 16 doubles, that could be a 4x4 array or a 2x8 array or a 1x16 array or a 16x1 array or....

The address of that array does not convey that information. How do you expect the compiler to resolve (and build into H2) a reference like H[1][2] when that could be the fifth item in the array (second row, third element of a 4x4) or the ninth item in the array (second row, third element of a 2x8) or whatever?

If you want the compiler to handle it, give the compiler the information. Pass sizes if they're variable, or define H2 so that it knows the size in advance. Voodoo isn't going to work, even if you have a bunch of dead chickens.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote