Jacob Meuser wrote: > Why does the following: > > [...] > > when compiled with: > > gcc -Wall -lm -o lrint lrint.c > > always complain: > > lrint.c: In function `main': > lrint.c:9: warning: implicit declaration of function `lrint' > > ? > > Works fine though.
lrint() is part of the C99 standard. If you add "-std=c99" or "-std=gnu99" to your compile line, the warning won't happen. It works fine because the function is in libc whether or not the compiler saw the declaration, so the linker works normally. Once upon a time (circa 1975-1980), common C practice was to declare practically nothing, and let the compiler and linker figure everything out. Prior to ANSI C, there were no function prototypes, for example. > Also, what's the difference between lrint() and (long)rint()? I mean, > why even have lrint? Faster because it's integer only? Take a look at <bits/mathinline.h>. If you can get the compiler flags right, you can compile lrint() into a single instruction, fistpl. That would seem to be faster than the two-or-more instruction sequence of rounding the double, then converting to int. This compiler invocation will generate the fistpl instruction on my compiler (gcc 3.2.3 gentoo), though it's far from fully optimized. gcc -o lrint -Wall -std=gnu99 lrint.c -O -lm C is truly portable assembler. -- Bob Miller K<bob> kbobsoft software consulting http://kbobsoft.com [EMAIL PROTECTED] _______________________________________________ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug