const arrays in prototypes
diamond@tkovoa
diamond at tkou02.enet.dec.com
Tue May 29 11:44:07 AEST 1990
In article <1990May26.164834.4211 at jarvis.csri.toronto.edu> norvell at csri.toronto.edu (Theo Norvell) writes:
>>Perhaps you mean
>> void DISALLOW( const int (*const mat)[2] )
>>But this is UGLY.
It's as ugly as any other solution, and as ugly as most of C.
>>Is the following a solution?
>> typedef const int const_matrix[2][2] ;
>> ...
>> void DISALLOW( const const_matrix mat )
>>If not, I'm sure someone will point out why.
This is also valid.
But you know the net. Even if it's a solution, we can still trust
someone to point out why it isn't. ;-)
In article <1359 at crabcake> zhu at crabcake.cs.jhu.edu (Benjamin Zhu) writes:
> Nope. In this case, "const" has been used twice, i.e., it
> is duplicatedly declared, which I believe is illegal in
> Ansi stardard. Moreover, I fail to notice any semantical
> difference between "const_matrix" and "const const_matrix".
> Maybe you mean something else?
Mr. Zhu, you have gotten this one wrong twice. Looks like you should
take a vacation from answering questions, until you're more alert.
typedef const int const_matrix[2][2] ;
means that a variable of type const_matrix will have constant elements.
void DISALLOW( const const_matrix mat )
means that the pointer "mat" is a constant pointer.
So the result is a constant pointer to constant elements.
The two "const"s do not duplicate each other.
--
Norman Diamond, Nihon DEC diamond at tkou02.enet.dec.com
Proposed group comp.networks.load-reduction: send your "yes" vote to /dev/null.
More information about the Comp.std.c
mailing list