NO

Author Topic: Constant expressions  (Read 4449 times)

Sanguis

  • Guest
Constant expressions
« on: June 15, 2007, 01:02:30 PM »
Hello,

I noticed that, if I have this code in Pelles C:
Code: [Select]
int a = 5 + 3 * (6 | 3 & 2) / 3;
The compiler generates code that moves a constant number to the address of "a",
so the (quite complicated) expression is calculated at compile-time!
So the question is: is there a sort of function available can "compile" constant expressions (I
mean expressions that only have constants in them)?
I googled and searched in the forum but I didn't find anything (at least nothing not-interpreter-ish).
If not, I'll try to write it myself, but I'am not that good in re-inventing =].

Thanks for any replies!