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
You must link against the math library:
gcc program.c -lm
The reason is that GCC (and some other compilers) have a built-in pow()
function for literal constants. So if you call pow()
with 2.0 manually, the compiler will actually figure-out what the answer is and substitute that for you. With a variable input, the compiler must rely on the math library, which you must link against.