Re: Build-in sqrt()?




On 11月27日, 下午12时22分, "santosh" <santosh....@xxxxxxxxx>
wrote:
peng.xia...@xxxxxxxxx wrote:
hello everyone,

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

#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

someone can give me a hint? i'm using a gcc-4.1.2 with glibc2.4.1 under
linuxThe actual details of creating executable code from C source is
implementation dependant and the C standard says nothing about it.
Under UNIX it is traditionally the case that the math library is a
seperate file and hence has to be specifically included at link time. A
specific implementation may well include the math functions along with
the rest of the standard C library.

Standard C, and this group, really has nothing to say about your
observation.

Sorry for my asking such a question in comp.lang.c. I post the problem
here because I doubt whether strange behaviour only caused by the
compiler and not something related to linker. So i ask is there a
build-in sqrt() in the topic.

Thank you all the same

.