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: Brian Dessent <brian at dessent dot net>
- To: Florian Gleixner <flo at redflo dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 13 Jun 2007 02:13:02 -0700
- Subject: Re: dealing with built-in functions
- References: <466F1653.6080508@redflo.de>
- Reply-to: gcc-help at gcc dot gnu dot org
Florian Gleixner wrote:
> gcc r.c -lm
> r.c: In function 'main':
> r.c:9: warning: incompatible implicit declaration of built-in function
> 'round'
I'm assuming that your C library is glibc, i.e. you're using Linux. It
is always a good idea to state what platform you are using, because gcc
supports many dozens of platforms so don't assume we know what you're
using.
The problem you are seeing is that glibc has a number of feature levels
that it supports. By default, it only exposes a fraction of available
features (C90) in its headers. You have to explicitly define the level
of feature support that you want:
<http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html>.
Defining _GNU_SOURCE gets you everything and is the most commonly used,
e.g. by adding -D_GNU_SOURCE to CFLAGS. I think that if you use
autoconf, it takes care of this for you if it detects you're on a glibc
system, but I could be wrong.
double() is a C99 feature, so without any feature defines glibc's math.h
does not declare it. Thus to avoid the warning and still used the
optimized gcc builtin, you just need to define _GNU_SOURCE (or
_ISOC99_SOURCE).
Brian