Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!wuarchive!texbell!vector!attctc!bobc From: bobc@attctc.Dallas.TX.US (Bob Calbridge) Newsgroups: comp.lang.c Subject: evaluation order Keywords: which way Message-ID: <9361@attctc.Dallas.TX.US> Date: 14 Sep 89 00:51:45 GMT Distribution: na Organization: The Unix(R) Connection, Dallas, Texas Lines: 26 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! - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=