In the first case fmax
probably gets optimised away at compile time. In the second case it does not and you then get a link error. Without knowing what compiler you are using it's hard to give a specific remedy, but if it's gcc then you may need to add -lm
, e.g.
c99 -Wall fmax_test.c -lm
Note also that fmax
is for double
s - you should be using fmaxf
for float
s.