🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1300

Re: const arrays in prototypes

#1300
From: Benjamin Zhu
Date: Sat, 26 May 1990 18:04
35 lines
1710 bytes
In article <2781@sunset.MATH.UCLA.EDU> pmontgom@euphemia.math.ucla.edu (Peter Montgomery) writes:
>[lots of stuffs deleted]
>	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?  For example,
>*/
>
>void DISALLOW(const int mat[2][2])
 
	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.

>{
>    mat++;		/* I want to forbid this usage.		       */	
>    mat[0][1] = 4;	/* Gcc 1.37.1 properly warns about this line.  */
>}
>
>--
>--------
>        Peter Montgomery
>        pmontgom@MATH.UCLA.EDU 
>	Department of Mathematics, UCLA, Los Angeles, CA 90024

Benjamin Zhu

+=========================================================================+
+Disclaimer:								  +
+	I do not represent Johns Hopkins, Johns Hopkins does not	  +
+	represent me either.						  +
+==========================================================================
Technical Details
Message-ID: <1356@crabcake>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!umd5!crabcake!zhu
References: <2781@sunset.MATH.UCLA.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!umd5!crabcake!zhu
From: zhu@crabcake.cs.jhu.edu (Benjamin Zhu)
Newsgroups: comp.std.c
Subject: Re: const arrays in prototypes
Message-ID: <1356@crabcake>
Date: 26 May 90 18:04:11 GMT
References: <2781@sunset.MATH.UCLA.EDU>
Reply-To: zhu@crabcake.cs.jhu.edu (Benjamin Zhu)
Followup-To: comp.std.c
Organization: JHU Computer Science Dept -- Town of Solitude
Lines: 35