compatibility of types

Rex Jaeschke rex at aussie.UUCP
Thu Jul 12 07:29:48 AEST 1990


> diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
> 
> However, you might want to beware of a subtle difference regarding
> some types that you did not ask about.  int(*)[3] and int(*)[5] also
> point to integers, but they are not compatible with each other.
> It's a bit too subtle for me to figure out if each is compatible
> with int* or not.

A pointer to an array of x int is NOT assignment-compatible to a pointer
to an array of y int nor to a pointer to an int.  You MUST use an
explicit cast to compare/copy etc.  them or to mix them when calling a 
function in the presence of such a prototype. It is conceivable that a 
pointer to an array might be a "fat" pointer containing information 
about the underlying array size giving it a different representation 
to a straight int pointer.

Rex

----------------------------------------------------------------------------
Rex Jaeschke     |  Journal of C Language Translation  | C Users Journal
(703) 860-0091   |        2051 Swans Neck Way          | DEC PROFESSIONAL
uunet!aussie!rex |     Reston, Virginia 22091, USA     | Programmers Journal
----------------------------------------------------------------------------
Convener of the Numerical C Extensions Group (NCEG)
----------------------------------------------------------------------------



More information about the Comp.std.c mailing list