autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: uint64_t fails with C++


From: Nick Bowler
Subject: Re: uint64_t fails with C++
Date: Wed, 7 Dec 2011 17:20:26 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On 2011-12-07 16:58 -0500, Mike Frysinger wrote:
> On Wednesday 07 December 2011 16:18:26 Nick Bowler wrote:
> > On 2011-12-07 15:31 -0500, Mike Frysinger wrote:
> > > i thought __STDC_LIMIT_MACROS was part of the spec and thus not
> > > "implementation dependent" ?
> > 
> > Sort-of.  It is included non-normatively in the C specification as a
> > recommendation to C++ implementations.  C++98 didn't include these
> > macros at all, and thus had nothing to say on the subject.
> > 
> > Nevertheless, the latest revision of the C++ specification includes
> > these macros, and explicitly states that you do *not* need to define
> > __STDC_LIMIT_MACROS to get them.
> 
> sorry, pronoun confusion ... i think you're saying:
> latest rev of the C++ spec includes macros such as __STDC_LIMIT_MACROS, and 
> that the spec states that you do *not* need to define __STDC_LIMIT_MACROS in 
> order to have uint64_t and friends available when including stdint.h ?
> -mike

Argh, too many macros!  I'll try again with less pronouns.

There are several macros defined in stdint.h, which describe the limits
of the various integer types.  I'll call them the "limit macros".  These
macros look like

  INT64_MAX
  INT64_MIN
  UINT64_MAX
  etc.

and reflect the similar macros for other types defined in <limits.h>.
Note that uint64_t is *not* a macro.

The C99 specification says in a non-normative footnote that the limit
macros should only be defined on C++ implementations if the program
defines __STDC_LIMIT_MACROS prior to including <stdint.h>.  I have no
idea why this is in the C99 spec at all, but this footnote has been
removed in the current drafts for the next revision.

The C++11 spec actually includes the limit macros, and includes a note
(which, while non-normative, exists to clarify the actual specification)
that says a program does *not* need to define __STDC_LIMIT_MACROS prior
to including <stdint.h>: the limit macros are defined unconditionally.
This is the only mention of __STDC_LIMIT_MACROS in the entire C++11
specification.

C++98 (which predates C99) did not include the limit macros at all, and
does not mention __STDC_LIMIT_MACROS.

Hope that is clearer,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]