evaluation order
Bob Calbridge
bobc at attctc.Dallas.TX.US
Thu Sep 14 10:51:45 AEST 1989
Is there any way to guarantee the order in which certain functions are
evaluated? By way of example, if I wanted to avoid the replication of
of strlen() in the following example:
if (write(handle, buf, strlen(buf)) != strlen(buf)) do_something();
by using rephrasing it like:
if (write(handle, buf, len=strlen(buf)) != len) do_something();
can I be assured that 'len' will be assigned the length of 'buf' before it
is used on the right side of the comparison operator. I understand that
some optimizing compilers may do some odd re-arranging and I'm worried that
the value of 'len' before excuting this line of code may be used on the
right side. Is this really possible? Are there any assurances?
I know that I can try this with my compiler and some test code but would it
be portable?
thanks,
Bob
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
= I know it's petty.......... =
- But I have to justify my salary! -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
More information about the Comp.lang.c
mailing list