* Compiling expressions
@ 2007-12-15 17:11 Antonio Eduardo Fermiano
2007-12-17 15:28 ` Andrew Haley
2007-12-19 8:14 ` 龙海涛
0 siblings, 2 replies; 3+ messages in thread
From: Antonio Eduardo Fermiano @ 2007-12-15 17:11 UTC (permalink / raw)
To: gcc-help
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?
Thank you :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Compiling expressions
2007-12-15 17:11 Compiling expressions Antonio Eduardo Fermiano
@ 2007-12-17 15:28 ` Andrew Haley
2007-12-19 8:14 ` 龙海涛
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2007-12-17 15:28 UTC (permalink / raw)
To: Antonio Eduardo Fermiano; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Compiling expressions
2007-12-15 17:11 Compiling expressions Antonio Eduardo Fermiano
2007-12-17 15:28 ` Andrew Haley
@ 2007-12-19 8:14 ` 龙海涛
1 sibling, 0 replies; 3+ messages in thread
From: 龙海涛 @ 2007-12-19 8:14 UTC (permalink / raw)
To: Antonio Eduardo Fermiano; +Cc: gcc-help
On Sat, 2007-12-15 at 15:11 -0200, Antonio Eduardo Fermiano wrote:
> 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?
i think you can search "constant folding" for more information
>
> Thank you :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-19 8:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-15 17:11 Compiling expressions Antonio Eduardo Fermiano
2007-12-17 15:28 ` Andrew Haley
2007-12-19 8:14 ` 龙海涛
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).