Let's say I have the following code snippet:
int i; double value;
for(i = 0; i < CONSTANT; i++) {
value = (double)pow(2, i);
}
Trying to compile this code yields an "undefined reference to `pow'" error.
Including or excluding math.h
makes no difference, since it ends up being included anyway.
Raising 2.0
to a hardcoded power works okay, but everything fails if I substitute the exponent by an expression that contains i
.
What am I doing wrong? Thanks.