0

I just encountered a strange thing. While testing math.h I tried to use pow() and compile it. I did not have to link math.h . But when I try the same with something like fmod() I have to link math.h while compiling the programm. Why do I have to link the library in the second case but not in the first?

0

1 Answer 1

2

Your compiler may be replacing some usages of pow with a constant. For example, it could replace pow(2.0, 3.0) with 8.0. This is a good optimisation and means you no longer need the pow in math.h.

But your compiler probably can't replace fmod, or all usages of math functions, so it still needs to link to the math library.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.