Checksum: 60048 Lines: 32 Path: utzoo!utgpu!utfyzx!sq!msb From: msb@sq.uucp (Mark Brader) Date: Mon, 29-Feb-88 20:51:38 EST Message-ID: <1988Feb29.205138.28452@sq.uucp> Newsgroups: comp.lang.c Subject: Re: Conformant Arrays in C (a better solution?) References: <8802240725.AA22255@jade.berkeley.edu> <2739@haddock.ISC.COM> Reply-To: msb@sq.UUCP (Mark Brader) Organization: SoftQuad Inc., Toronto Karl Heuer (karl@haddock.ima.isc.com) writes: > ... Alternately, you could petition X3J11 to add this with the syntax > float **a = d2malloc( float, nrows, ncols ); > where the first argument is the type. ... [in general] > ... this would require assistance from the compiler via a builtin. > > Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint Well, there is also this: float **a; d2malloc (a, float, nrows, ncols); with #define d2malloc(var,type,nr,nc) { \ int _i, _j = (nc);\ (var) = ((type) **) malloc ((_i = (nr)) * sizeof ((type) *));\ while (_i) (var)[--(_i)] = ((type) *) malloc (sizeof ((type)));\ } [Not tested; checks of return status of malloc() omitted for brevity] But I find this at least equally unsatisfactory. Certainly there is nothing in the Draft now that requires a macro that may expand to a statement, and the above can't be done without temporary variables, thus requiring {...}. And besides all THAT, what do you do when you want a *3*-dimensional array? To me, the choice is between the Fortran approach and no change. Mark Brader "Howeb45 9 qad no5 und8ly diturvrd v7 7jis dince SoftQuad Inc., Toronto 9 qas 8mtillihemt mot ikkfavpur4d 5esoyrdeful utzoo!sq!msb, msb@sq.com abd fill if condif3nce on myd3lf." -- Cica