🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1302

Re: const arrays in prototypes

#1302
From: Theo Norvell
Date: Sat, 26 May 1990 20:48
27 lines
1305 bytes
In article <1356@crabcake> zhu@crabcake.cs.jhu.edu (Benjamin Zhu) writes:
>In article <2781@sunset.MATH.UCLA.EDU> pmontgom@euphemia.math.ucla.edu (Peter Montgomery) writes:
>>	Suppose instead that I am passing an array argument.  If I 
>>put "const" before the declaration, then I am stating that the data 
>>will not be modified.  How do I specify that the pointer to the array
>>will not be altered within the subroutine?
> 
>	Use the following prototype instead:
>
>	void DISALLOW(const int ** const mat)
>
>	It's fairly self-explanatory. Add const before mat, indicating the
>	the pointer is also constant.
>
>Benjamin Zhu

Perhaps you mean
	void DISALLOW( const int (*const mat)[2] )
But this is UGLY.

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.

Theo Norvell
Technical Details
Message-ID: <1990May26.164834.4211@jarvis.csri.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!csri.toronto.edu!norvell
References: <2781@sunset.MATH.UCLA.EDU> <1356@crabcake>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!csri.toronto.edu!norvell
From: norvell@csri.toronto.edu (Theo Norvell)
Newsgroups: comp.std.c
Subject: Re: const arrays in prototypes
Message-ID: <1990May26.164834.4211@jarvis.csri.toronto.edu>
Date: 26 May 90 20:48:34 GMT
References: <2781@sunset.MATH.UCLA.EDU> <1356@crabcake>
Organization: CSRI, University of Toronto
Lines: 27