Compiling expressions

Andrew Haley aph@redhat.com
Mon Dec 17 15:28:00 GMT 2007


Antonio Eduardo Fermiano writes:
 > This is the third newbie question I make here, but...
 > 
 > If I put, for example:
 > 
 > variable = 1 + 2;
 > 
 > gcc will compile the code for the CPU add one to two and put in
 > variable, in execution time, or will substitute and in the compiled
 > code the equivalent of:
 > 
 > variable  = 3;
 > 
 > would be inserted?
 > 
 > If it evaluate expressions like this before compiling, it always is
 > done? Or I would need some directive to ask gcc to evaluate it for me
 > before compiling?

gcc always at compile time substitutes 3 for the expression 1 + 2 .

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903



More information about the Gcc-help mailing list