union *func()

Chris Torek chris at mimsy.UUCP
Thu Oct 27 04:27:14 AEST 1988


In article <2205 at arcturus> evil at arcturus.UUCP (Wade Guthrie) writes:
>Is the following code portable, strictly conforming, etc.
>	a = function()->member;
>as in something like the following (really simplified) code:
[deleted]

It is conforming, etc., if function() returns a pointer to a structure
or union and the `member' field corresponds to a member of that
structure or union.  Likewise,

	a = function().member;

is conforming, etc., if function() returns a structure or union and the
`member' field corresponds, etc., with one additional restriction: the
member must not be an array.

Nonetheless, the second form is another one of those things that
compilers have got wrong in the past; you are better off with

	lump = function();
	a = lump.member;
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.std.c mailing list