Union Problem on Sparc
Bradley E. Smith
brad at ds3.bradley.edu
Sun Nov 4 14:00:00 AEST 1990
Hi, I realize that the program below is not quite right(or proper) but I
am trying to move our 'pic' source from a VAX to a SUN SPARC. The below
program works ok on a VAX, AT&T 3B2, IBM RT but dumps core on a SUN. I
always thought that unions were passed by value. Anyways I need this
program to work, or I will have to rewrite a bunch of things.
Is it me or is the compiler bugging (FYI: 4.0.3 and 4.1 have the same
problem, and gcc does the same thing).
union u {
int i;
long l;
char c;
float f;
char *cp;
};
main()
{
union u x,z;
x.i = 100;
z.i = 99;
printf("sizeof(u) = %d\n", sizeof(x));
printf("sizeof(int) = %d\n", sizeof(int));
(void) doit(x,z);
(void) doit(0,0);
exit(0);
}
doit(a,b)
union u a;
union u b;
{
(void) printf("%d, %d\n", a.i, b.i);
}
More information about the Comp.sys.sun
mailing list