This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dealing with built-in functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]