Am Fre, 2003-06-27 um 10.17 schrieb Bernhard Walle:
Hallo,
folgendes Problem:
,----[ test.c ]- | #include
| #include | | int main (int argc, char** argv) | { | printf("%f\n", round(0.5)); | | return 0; | } `---- [~] $ gcc -W -Wall -Wno-unused -lm -o test test.c test.c: In function `main': test.c:6: warning: implicit declaration of function `round' test.c:6: warning: double format, different type arg (arg 2)
man round .. CONFORMING TO C99. .. Beachte C99 !!! => gcc -Wall -std=c99 -o test test.c -lm D.h. in c89 (aka ANSI-C) gibt es round nicht, ceil oder floor hingegen sind C89-konform.
Das Ergebnis ist auch unbrauchbar (2.890182). Warum? Da Du nicht -std=c99 verwendest, ist round nicht deklariert => Implizit deklariert als "int round()" => Warnung "double format, ..."
=> Der Linker nimmt ein anderes round als das von dir beabsichtigte => Gesamtverhalten des Progs ist Murks. Ralf