Message-ID: <3166A608.33A@public1.guangzhou.gd.cn> Date: Sun, 07 Apr 1996 01:12:40 +0800 From: Wang TianXing Organization: No Organization MIME-Version: 1.0 To: DJGPP Subject: Re: C Question References: <9604051057 DOT AA52478 AT ibm1 DOT cicrp DOT jussieu DOT fr> <4k34l7$b4k AT news DOT cea DOT fr> Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit > >I simply have several question in mind about compilation of C. > > > >When I do: > >int i; > > > >i=3+4; > > > >Does GCC generate i=7 or i=3+4 ? > > > >I suppose the answer is the same for > >i=0x01 | 0x02 which is equal to i=0x03 > > > >Again, in: > >#define FIVE 3+2 > > > >is it the same, for the compiled program as #define FIVE 5 ? I tried the following function with gcc -S -g: int f( int n ) { return 3 + n + 4; } gcc generated something equivallent to 'return 7 + n;'. If I recall correctly, in The C Language, 1st ed., K&R said that C compilers almost always(note that I turned the debugging option, -g, on) do such kind of optimizations. That's why the orders of sub-expression evalutions in C are unspecified - C compilers are expected to do so many optimizations. BTW, if you may use FIVE in contexts such as (3*FIVE), you'd better write #define FIVE 3+2 as #define FIVE (3+2) Regards, Wang TianXing