Re: uint_least32_t is in stdint.h not in inttypes.h

2020-12-03 Thread Hans Åberg

> On 16 Nov 2020, at 10:53, Torbjörn Granlund  wrote:
> 
> Vincent Lefevre  writes:
> 
>  So, including  if present should be sufficient, and
>  this is what the above code does.
> 
>  That said, for C99 implementations, the #if tests would be useless,
>  so that the above code is also designed for non-C99 implementations,
>  which may have  and  with a behavior different
>  from C99, i.e.  will not necessarily include 
>  (but this also means that  will not necessarily have
>  uint_least32_t).
> 
> The mainline gmp repository and the next major GMP release (7.0) will
> require a C99 compiler.  I believe we have not fully determined which
> C++ standard we will require (or, Marc, did we come to a conclusion?).
> We will use C99 constructs and will gradually clean up code which
> handles older environments.

GCC has as default C++14, skipping over C++11 as the implementation was 
complicated, the latter which in turn first defined the corresponding headers.

https://en.cppreference.com/w/cpp/types/integer
https://en.cppreference.com/w/c/types/integer


___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: uint_least32_t is in stdint.h not in inttypes.h

2020-11-16 Thread Torbjörn Granlund
Vincent Lefevre  writes:

  So, including  if present should be sufficient, and
  this is what the above code does.

  That said, for C99 implementations, the #if tests would be useless,
  so that the above code is also designed for non-C99 implementations,
  which may have  and  with a behavior different
  from C99, i.e.  will not necessarily include 
  (but this also means that  will not necessarily have
  uint_least32_t).

The mainline gmp repository and the next major GMP release (7.0) will
require a C99 compiler.  I believe we have not fully determined which
C++ standard we will require (or, Marc, did we come to a conclusion?).
We will use C99 constructs and will gradually clean up code which
handles older environments.

In the meantime, GMP 6 will continue to support C89.  We actually
removed some accidental C99ism with the 6.2.1 release.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: uint_least32_t is in stdint.h not in inttypes.h

2020-11-15 Thread Felix von Leitner
> But ISO C99 says:

>   7.8 Format conversion of integer types 

>   The header  includes the header  [...]

> So, including  if present should be sufficient, and
> this is what the above code does.

Oh NICE that means I got a bugfix for my code out of this, too.

Thanks! :-)

Godspeed, Vincent. GMP is awesome.

Felix
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: uint_least32_t is in stdint.h not in inttypes.h

2020-11-15 Thread Vincent Lefevre
On 2020-11-15 22:21:18 +0100, Felix von Leitner wrote:
> I was trying to compile gmp with my libc, dietlibc, and got an error
> that uint_least32_t is not defined.
> 
> Well, it is defined, and as far as I can tell in the right header file,
> too: stdint.h.
> 
> However, gmp-impl.h reads as follows:
> 
>  155 #if HAVE_INTTYPES_H  /* for uint_least32_t */
>  156 # include 
>  157 #else
>  158 # if HAVE_STDINT_H
>  159 #  include 
>  160 # endif
>  161 #endif
> 
> Note that stdint.h is in the else clause. dietlibc has both
> inttypes.h and stdint.h.

But ISO C99 says:

  7.8 Format conversion of integer types 

  The header  includes the header  [...]

So, including  if present should be sufficient, and
this is what the above code does.

That said, for C99 implementations, the #if tests would be useless,
so that the above code is also designed for non-C99 implementations,
which may have  and  with a behavior different
from C99, i.e.  will not necessarily include 
(but this also means that  will not necessarily have
uint_least32_t).

> Proposed fix: Move the #if HAVE_STDINT_H outside the previous #if.

Indeed, including both headers independently (when they are available)
may be the best way to have a chance to get uint_least32_t.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs