Structures

Nelson Minar,??? minar at reed.bitnet
Thu Mar 1 07:13:15 AEST 1990


My copy of K&R 1 (I'll be getting 2 soon..) says

"There are only two things that can be done with a structure or a union:
name one of its members (by means of the . operator); or take its address
(by unary &).  Other operations, such as assigning from or to it or passing
it as a parameter, draw an error message.  In the future, it is expected
that these operations, but not necessarily others, will be allowed."

1] What does ansi say about this?

2] It seems that passing a structure-by-value is illegal under this rule.
Why this limitation in the original C?

3] My C compiler (Turbo C 2.0) doesn't mind passing a structure-by-value,
and it allows you to set two structures equal to each other, automatically
copying the elements. Is this standard behavior for most C compilers? Why
does Turbo C have an <optional> warning "Warning: structure passed by value"
if it is legal TC 2.0 code? Because it is potentially non-portable?



More information about the Comp.lang.c mailing list