I have header files which instantiate 2-dimensional
arrays with const floats. When I compile the code below
with g++ -Wall, these initializations generate one of
the following warning messages for each line of data:
"warning: aggregate has a partly bracketed initializer"
What is the preferred method to initialize 2-dimensional
arrays? I am looking for a method which does not generate
warning messages when compiled with g++ -Wall.
const long nbr_LSM_pnt_typ(14);
const long nbr_mth_per_yr(12);
const float gai[nbr_LSM_pnt_typ+1][nbr_mth_per_yr]={
4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0,
0.0,0.0,0.0,0.6,1.2,2.0,2.6,1.7,1.0,0.5,0.2,0.0,
4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,
...
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; // end gai[]
Thanks,
Charlie
--
Charlie Zender Voice: (303) 497-1445, FAX: 497-1400
NCAR ACD & CGD E-mail: zen...@ncar.ucar.edu
P.O. Box 3000 URL: http://www.cgd.ucar.edu/cms/zender
Boulder CO 80307-3000 PGP: finger -l zen...@goldhill.cgd.ucar.edu
Put brace brackets around each 'row' of your 2-d array, e.g.:
{4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0},
{0.0,0.0,0.0,0.6,1.2,2.0,2.6,1.7,1.0,0.5,0.2,0.0},
and so on.
Tip: for readability, put a space after each comma - commas and dots can be
difficult to distinguish on some monitors.
--
Jim
I ignore all email from recruitment agencies.
Please do not send me email with questions - post here.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own