bk19+@andrew.cmu.edu (Bradley D. Keister) (12/19/89)
I'm running cfront 2.0 on a DECstation. It appears that several options
for initializing an array of classes does not work. I have a class called
three_vector {double x, y, z; ... } for which I'd like to have an array
xi[3]. Just declaring three_vector xi[3] yields
"W.c", line 113: sorry, not implemented: default arguments for constructor
for array of class three_vector
If I do this:
three_vector xi[3] = {(1, 0, 0), (0, 1, 0), (0, 0, 1)};
I find upon printing that xi hasn't been initialized properly.
If I define static quantities e_x(1, 0, 0), etc. and then define
three_vector xi[3] = {e_x, e_y, e_z};
I get the following from the backend C compiler:
ccom: Error: W.c, line 113: __1__Xr00a2jkaimo undefined
( ( ((*( (__1__Xr00a2jkaimo = (struct three_vector *)(& e_z )),
( (((& (__1xi [0]))|| (__nw__FUi ( sizeof (struct three_vector)) ))?(
----------------------------^
ccom: Warning: W.c, line 113: illegal combination of pointer and integer, op =
( ( ((*( (__1__Xr00a2jkaimo = (struct three_vector *)(& e_z )),
( (((& (__1xi [0]))|| (__nw__FUi ( sizeof (struct three_vector)) ))?(
-------------------------------------------------------------^
ccom: Error: W.c, line 113: illegal indirection
((& (__1xi [0]))-> x__12three_vector
= ((*__1__Xr00a2jkaimo )). x__12three_vector ), ( ((& (__1xi [0]))->
y__12three_vector = ((*__1__Xr00a2jkaimo )). y__12three_vector ),
((& (__1xi [0]))-> z__12three_vector =
------------------------------------------------------------^
...etc, etc...
The only thing that works is to make a direct assignment in the code. Is
this the right thing to do, or am I missing something?
Brad Keister
Physics Department
Carnegie Mellon U
keister@iguana.psc.edu