News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Constant expressions

Started by Sanguis, June 15, 2007, 01:02:30 PM

Previous topic - Next topic

Sanguis

Hello,

I noticed that, if I have this code in Pelles C:

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!