"PraZ" <prasanna.sethuraman@patni.com> wrote in message
news:1143626106.137290.294600@e56g2000cwe.googlegr oups.com...
: Here is a simple code, which when compiled with gcc results in the
: warning "incompatible pointer type" for arg 1, as expected. But this is
: just what I want to do, because it makes it easy for me to handle the
: single dimensional stream I have as a multidimensional array inside the
: function func(). Now, I am just wondering if there is a way by which I
: can disable this incompatible pointer type warning in gcc. Any
: suggestions?
....
: void func(char [2][2]);
....
: char* src;
....
: func(src+4);
You can explicitly cast the parameter to the appropriate type:
func( (char(*)[2]) (src+4) );
But to me, it looks like func() might well be inapropriately
exposing implementation details in its interface.
If any 4-char sequence is acceptable as an input, the interface
should not expose a [2][2] bidimensional array to its callers.
If it is really useful for the implementation, func() could
create a local variable of the desired type:
void func( char const src[4] ) // include const if not modified
{
char (*tab)[2] = (char(*)[2])src;
...use tab as needed...
}
Regards -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com