Re: Build-in sqrt()?




Jack Klein wrote:
On 26 Nov 2006 20:05:09 -0800, "peng.xiaoyu@xxxxxxxxx"
<peng.xiaoyu@xxxxxxxxx> wrote in comp.lang.c:


hello everyone,

why this c code can be compiled and linked without -lm?

What's "-lm"? It's nothing defined by the C language. If it's
something that you think your implementation needs, you should be
asking in a support group for your implementation.

....siding with Kevin McCormack here...

What possible good does your reply serve? Some dude asks about libm.a
and a half dozen people reply with "OMG THAT'S NOT IN THE
STANDARDS!!!!!111eleven!!!!"

Why not just not reply if all your going to do is prove your inability
to answer a fucking question.

For the record, at least with GCC 4.1.1 on my Fedora box the test
program

#include <math.h>
double f(double y) { return sqrt(y); }

Will have "U sqrt" in the nm output. If you add "-ffast-math" it may
not (in my case it used the SSE2 instruction "sqrtsd" to perform the
operation) be present.

Why you didn't see it could be because it's been inlined (intrinsic).
However, you should link libm.a in for platforms/build settings where
that is not the case.

Wow, was that really so hard?

Tom

.


Quantcast