Re: Build-in sqrt()?



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.

#include<math.h>
#include<stdio.h>
int main()
{
printf("%f\n",sqrt(2.0));
return 0;
}

even NO sqrt symbol when i use nm to list symbols from the object file

The C standard names no mention of "nm", or what it is supposed to do.
Again, a platform specific group is appropriate and could probably
provide more useful information.

someone can give me a hint? i'm using a gcc-4.1.2 with glibc2.4.1 under
linux

best regards

Among other possibilities, the as-if rule allows the implementation to
replace the call of a standard library function with a constant value
with its known result. It could merely pass
1.4142135623730950488016887242097, or perhaps some shorter version
thereof, to printf() without calling sqrt() at all.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
.