(Ben Pfaff) writes:
>One difference is that Fibonacci numbers generated by the
>preprocessor could (presumably) be used in initializers and other
>constant expressions. Functions calls cannot appear in constant
>expressions.
The following language change might be more safe than the
one proposed in the OP:
static static int example( int const i ){ return i + 1; }
A static-static function call expression MUST BE evaluated
at compile time by the compiler and the compiler MUST
issue an error message if it cannot do this.
Then, given that f is a static-static function and
i_(0), i_(1), ... i(n-1) already are compile-time constants,
f( i_(0), i_(1), ..., i_(n-1) )
also is a compile time constant.
Evaluating a static-static function call should not be
that hard for a compiler, since it can compile the function
and then call it with the argument values already known.
(Ok, assuming it is not a cross compiler! - But even a
cross compiler can do this, when it is the programmers
duty to keep the result portable.)
I am not seriously suggesting this change to the C language,
I only want to say that this would allow the OP to do his
calculation at compile time, while it might be more safe
than a preprocessor extension.