allocating arrays

Brandon Allbery allbery at ncoast.UUCP
Thu May 8 08:21:12 AEST 1986


Expires:

Quoted from <200 at pyuxv.UUCP> ["Microsoft 'C' - Strange behaviour with doubles"], by cim2 at pyuxv.UUCP (Robert L. Fair)...
+---------------
| Consider an array of 15 pointers to arrays of doubles:
| 
| 	double (*parray[15])[];
| 
| The following code to 'malloc' the actual double array barfs on Microsoft 'C',
| with a 'different levels of indirection' warning on the '='.
| The code passes through LINT, and compiles OK on UN*X 5.2
| 
| 	char	*malloc();
| 
| 	parray[0] = (double*)malloc((unsigned)sizeof(double)*75);
| 
| Microsoft produces the same error if the coercion is (double**), (double),
| or nothing at all !
| 
| Any ideas ?
+---------------

double (*parray[15])[]; means:

	an indefinitely-sized array of (or a pointer to)
		an array of 15
			(double *)

You want to allocate an array[15] of (double *)?  ``double *parray[15];''
                  ...an array of 15 (double)?  ``double parray[15][];''

My compiler (pcc) won't even TAKE ``double (*parray[15])[];'' unless it's
initialized or external; apparently sys5 converts it to the declaration
``double *(*parray[15]);'' -- ptr to array[15] of (double *) -- automatically.

--Brandon
-- 
decvax!cwruecmp!ncoast!allbery  ncoast!allbery at Case.CSNET  ncoast!tdi2!brandon
(ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060-4101
Phone: +01 216 974 9210      CIS 74106,1032      MCI MAIL BALLBERY (part-time)
PC UNIX/UNIX PC - which do you like best?  See <1129 at ncoast.UUCP> in net.unix.



More information about the Comp.lang.c mailing list