Hi,
i try to write the following c++ program:
....
static const int row=(dynamic_cast<int>(log(BHR_LEN*G_PHT_COUNT)/log(2)));
static const int pht_bits=((32*1024)/(G_PHT_COUNT * G_PHT_COUNT * BHR_LEN));
unsigned char tab[pht_bits][1<<row];
...
and here i get the error message double log(double)’ cannot appear in a constant-expression.
why do i get this problem since i have put an integer cast in front? how can i fix this?
thank you very much!
That's how it is. You cannot put a function where a constant is needed, even if the function's arguments are constant. Consider for example what would happen if you put rand() there. All (zero) arguments are constant but this function cannot be evaluated in compile time.
I think C++1x will fix this with constexpr keyword, but I'm not sure..