structure assignment in dpANSI

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Nov 11 03:20:56 AEST 1988


In article <11077 at elroy.Jpl.Nasa.Gov> djb at spacely.Jpl.Nasa.Gov (Daniel J. Burns) writes:
>The definition of compatible types for structures is unclear to me.
>Is the following legal?
>	struct { int x ; float y ; } a ;
>	struct { int x ; float y ; } b ;
>	a = b ;  /* ??? */

Assuming that a and b are declared in the same translation unit,
they have different types and are not compatible.  (If they were
declared in separate translation units, they would have different
but compatible types.)

Therefore if you need for something along the above lines to work,
you should use struct tag or a typedef in place of a struct{...}
style of declaration.



More information about the Comp.std.c mailing list