This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: dealing with built-in functions
- From: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- To: Florian Gleixner <flo at redflo dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 13 Jun 2007 10:36:14 +0100
- Subject: Re: dealing with built-in functions
- References: <466F1653.6080508@redflo.de>
Florian Gleixner writes:
> Hi,
>
> i try to fugure out what is the "best way". The following code throws a
> warning:
>
> #include <stdio.h>
> #include <math.h>
>
> int main(void)
> {
> double x=1.7;
> printf("%f %f",x,round(x));
> }
>
> gcc r.c -lm
> r.c: In function 'main':
> r.c:9: warning: incompatible implicit declaration of built-in function
> 'round'
>
> I can avoid this by using the compiler switch -fno-builtin. But as far
> as i understand, the built in functions are optimized. So if i use
> -fno-builtin, i lose some cycles?
> I can also put at line 3:
> extern double round(double);
> and then i don't need the -fno-builtin. But what does that mean? Which
> round() do i use then? Can i avoid the warning if i use other types of
> variables - i don't know how the built-in round() is defined.
> Other thoughts?
Look at the Fine Man Page:
NAME
round, roundf, roundl - round to nearest integer, away from zero
SYNOPSIS
#include <math.h>
double round(double x);
float roundf(float x);
long double roundl(long double x);
Compile with -std=c99; link with -lm.
Note the last line.
Andrew.