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

Re: [win32] perl.h now defines INTMAX_C and UINTMAX_C

Thread Previous | Thread Next
From:
Karl Williamson
Date:
January 25, 2018 01:46
Subject:
Re: [win32] perl.h now defines INTMAX_C and UINTMAX_C
Message ID:
0e3b09c1-44ac-72c0-c2fb-2d3fe04ac347@khwilliamson.com
On 01/22/2018 09:10 PM, sisyphus1@optusnet.com.au wrote:
> 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 ?

Line 692 of perl.h includes stdint.h if Configure has found defined the 
symbol I_STDINT.  Maybe the windows config file should change to define 
that symbol.  I see that it currently isn't.  Maybe it should be done 
only for more recent releases?
> 
> 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 Previous | 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