Changes needed to make gmp 4.2.1 build with GCC trunk

Richard Guenther rguenther at suse.de
Mon Sep 3 17:20:36 CEST 2007


On Mon, 3 Sep 2007, Torbjorn Granlund wrote:

> Sorry for a quite slow reply!
> 
> In May, you wrote:
> 
>   GCC 4.3 will change inline semantics to be standard conforming to
>   C99.  The t-locale.cc test references abort(), so it should include
>   cstdlib.
>   
>   If those already are fixed in development sources just ignore this
>   post.
>   
> I worry about backwards compatibility of the C++ change.
> 
> Is <cstdio> available since the dawn of C++, or when was it added?

<cstdlib> that is.  Yes, <cstdlib> is required by the ISO C++ standard,
documented in "20.4.6 C Library".  Though only calloc, malloc, free
and realloc are explicitly listed it says "The contents are the same
as the Standard C library header <stdlib.h>, ..."

As alternative you can include <stdlib.h>, but this is not mandated
by the standard.


> The inline change is protected by __GNUC_STDC_INLINE__.  Is
> that in the official FSF gcc releases?

Yes, it was retroactively added to the 4.1 release and is
available for all 4.2 and 4.3 versions.  From the documentation:

""
@item gnu_inline
@cindex @code{gnu_inline} function attribute
This attribute should be used with a function which is also declared
with the @code{inline} keyword.  It directs GCC to treat the function
as if it were defined in gnu89 mode even when compiling in C99 or
gnu99 mode.

[...]

In C, if the function is neither @code{extern} nor @code{static}, then
the function is compiled as a standalone function, as well as being
inlined where possible.

This is how GCC traditionally handled functions declared
@code{inline}.  Since ISO C99 specifies a different semantics for
@code{inline}, this function attribute is provided as a transition
measure and as a useful feature in its own right.  This attribute is
available in GCC 4.1.3 and later.  It is available if either of the
preprocessor macros @code{__GNUC_GNU_INLINE__} or
@code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline 
Function is As Fast As a Macro}.
""

This is also how glibc was fixed.

Richard.

-- 
Richard Guenther <rguenther at suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


More information about the gmp-devel mailing list