I have this somewhat complex value (in that it results from combining multiple other values in some mathematically non-trivial way) which however only ever needs to be calculated once in the whole program execution. I tried to make them all static const
.
But the compiler complains that my inputs to my complex value must "have a constant value" - which they obviously do at compile time.
In this example, I want to compute c
from a
and b
once and for all. But the compiler complains that, in the assignment of c
, a
and b
must "have a constant value" - which they quite obviously do (seems to me).
void foo(void)
{
static const int a = 10, b = 2;
static const int c = a/b;
}