Compiling with C++

Marc Glisse marc.glisse at
Mon Nov 17 19:44:16 UTC 2014

On Mon, 17 Nov 2014, Torbjörn Granlund wrote:

> Marc Glisse <marc.glisse at> writes:
>  Interesting, we don't have a big extern "C" in longlong.h, I am
>  surprised we didn't hit issues with that earlier.
> It puzzled me too, but now I see why; longlong.h is quite innocent.
> These references are made only if HAVE_NATIVE_mpn_umul_ppmm, which
> happens if the config provides umul_ppmm as a function.  Now, x86
> (32-bit) provides that for all configs via in mpn/x86/umul.asm, but
> x86_64 does not.
> I am not sure how to best address this.  The motivation for these
> umul.asm files was to support non-GCC compilers better.
> Alternatives:
> 1. Remove the umul.asm files, and then the code depending on them in
>   longlong.h and tune/common.c (and perhaps more places).  This will
>   hurt proprietary compilers (and perhaps also clang).
> 2. Put extern "C" {....} in some good place around mpn_umul_ppmm and
>   mpn_udiv_qrnnd.  Perhaps longlong.h is the right place.  Or perhaps
>   gmp-impl.h.

If adding the usual:

#ifdef __cplusplus
extern "C" {


#ifdef __cplusplus

at the beginning / end of longlong.h works, that seems like a good 
solution. gmp.h and gmp-impl.h already have it.

> 3. Something else.
>  Seems to be mostly just the glibc 'throw()' thing.
> OK.

Marc Glisse

More information about the gmp-discuss mailing list