Re: Build-in sqrt()?



peng.xiaoyu@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
linux

The 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.

.