kyriazis@rpics (George Kyriazis) (10/08/88)
Hello. I am transfering a program from a Sun4 to an 4-D and I have the following problem: When I use a function that returns a structure as an argument to another function, incorrect results appear. Can anybody help me? A test program follows. It works fine on a Sun4 (and Sun3). Thanks. ------------------------------- struct vector {double x, y, z}; struct vector vadd(a,b) struct vector a,b; { struct vector c; c.x = a.x + b.x; c.y = a.y + b.y; c.z = a.z + b.z; return c; } struct vector svproduct(k, a) double k; struct vector a; { a.x *= k; a.y *= k; a.z *= k; return a; } main() { struct vector a,b,c,d,aa,bb; double sc; printf("v1: "); scanf("%lf %lf %lf", &a.x, &a.y, &a.z); printf("v2: "); scanf("%lf %lf %lf", &b.x, &b.y, &b.z); printf("scale: "); scanf("%lf", &sc); aa = svproduct(sc, a); bb = svproduct(sc, b); printf("a: %lf %lf %lf\n", aa.x, aa.y, aa.z); printf("b: %lf %lf %lf\n", bb.x, bb.y, bb.z); c = vadd(aa, bb); d = vadd(svproduct(sc,a),svproduct(sc,b)); printf("%lf %lf %lf\n", c.x, c.y, c.z); printf("%lf %lf %lf\n", d.x, d.y, d.z); } Output is as follows: v1: 1 0 0 v2: 0 1 0 scale: 2 a: 2.000000 0.000000 0.000000 b: 0.000000 2.000000 0.000000 2.000000 2.000000 0.000000 2.000000 2.000000 2.000000 George Kyriazis kyriazis@turing.cs.rpi.edu ------------------------------
skinner@saturn.ucsc.edu (Robert Skinner) (10/12/88)
In article <1373@imagine.PAWL.RPI.EDU>, kyriazis@rpics (George Kyriazis) writes: > > Hello. I am transfering a program from a Sun4 to an 4-D and I have > the following problem: When I use a function that returns a structure as > an argument to another function, incorrect results appear. Can anybody > help me? A test program follows. It works fine on a Sun4 (and Sun3). > Thanks. > structure passing is broken in release 3.0. it is fixed in 3.1. Robert Skinner