develooper Front page | perl.perl5.porters | Postings from January 2018

[win32] perl.h now defines INTMAX_C and UINTMAX_C

Thread Next
From:
sisyphus1
Date:
January 23, 2018 04:11
Subject:
[win32] perl.h now defines INTMAX_C and UINTMAX_C
Message ID:
7A07BDC79E814D9E8D1070C445D9FFBE@OwnerPC311012
Hi,

On Windows, as of 5.27.7, INTMAX_C and UINTMAX_C are being defined by
perl.h.
Both symbols are normally defined in stdint.h.
But stdint.h has not been included by the perl headers - and intmax_t and
uintmax.t are therefore unknown identifiers.

As a result, Math-MPFR-4.0.0 is broken on Windows for perl 5.27.7 and
5.27.8.

The mpfr library header (mpfr.h) considers that if INTMAX_C and UINTMAX_C
are defined, then stdint.h has been included - and intmax_t and uintmax_t
will be known types.
Therefore compilation of Math::MPFR fails as soon as the first intmax_t
identifier in mpfr.h is encountered.

Is this behaviour of perl.h wise/acceptable/desirable/allowable ?

If it's all of those, then it's no big deal - I think this issue with
Math-MPFR on Windows could be fixed in the XS code either by:
a) including inttypes.h just before including mpfr.h
or
b) '#undef INTMAX_C' and '#undef UINTMAX_C' just before including mpfr.h

(But if perl.h were to revert to not defining these symbols, then I won't
have to do anything ;-)

Here's a little demo script:

############################
use warnings;
use strict;

use Inline C => <<'EOC';

void foo() {
#if defined(_STDINT_H)
  printf("defined\n");
#else
  printf("not defined\n");
#endif

#if defined(INTMAX_C)
  printf("defined\n");
#else
  printf("not defined\n");
#endif

}

EOC

foo();
############################

I have perls 5.27.6 and 5.27.8, both configured identically (ivtype is long
long, ivsize is 8).
With 5.27.6 that script outputs:

not defined
not defined

With 5.27.8 it outputs:

not defined
defined

On Ubuntu (ivtype is long, ivsize is 8) with 5.27.8 the script outputs:

defined
defined

NOTE: I do wonder if the MPFR library should conclude that stdint.h has been
included simply on the basis that INTMAX_C and UINTMAX_C are defined.
I mean, if you want to know if stdint.h has been included, shouldn't you
check to see if _STDINT_H has been defined ?
But that's probably a question for a different list.

Cheers,
Rob 

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About