Question re external 2-dimensional arrays

Brian Noble noble at icsia3.ICSI.Berkeley.EDU
Thu Apr 25 07:37:34 AEST 1991


Howdy!

I have the following global array that is accessed by several source
modules...

double myArray[MAX1][MAX2];


The Question:  what is the least computationally expensive way to declare
this array as an external variable, so when I access an element in the array
the complier knows the row length and (cheaply) calculates the correct offset
into the array.

my first intuition is...

(1) define the following type:

typedef myArrayT[MAX1][MAX2];

(2) declare the array to be:

myArrayT myArray;

(3) and declare the external reference as

extern myArrayT myArray;

Will this work?  Is there a better way?

Please respond via email as I don't have time to keep up with comp.lang.c.
If there are a sufficient number of 'boy, I'd really like to know that too'
I'll summarrize to the net.

Brian Noble
noble at tenet.berkeley.edu



More information about the Comp.lang.c mailing list