Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Dec 2012 21:10:01 GMT
From:      "b.f." <bf1783@googlemail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/174549: UINT64_MAX missing in C++ Program
Message-ID:  <201212262110.qBQLA1C6076762@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/174549; it has been noted by GNATS.

From: "b.f." <bf1783@googlemail.com>
To: bug-followup@freebsd.org, Robin Carey <robin.carey1@googlemail.com>
Cc:  
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Wed, 26 Dec 2012 21:02:35 +0000

 On 12/26/12, Robin Carey <robin.carey1@googlemail.com> wrote:
 > Dear bf,
 >
 > I tried defining
 >
 > # define  __STDC_LIMIT_MACROS
 >
 > before the <stdint.h> inclusion (as you suggested), and it made no
 > difference - the error still occurs.
 >
 >
 > If you look at what gets included by <stdint.h>, you will see that that
 > definition is made in
 >
 > <sys/cdefs.h>
 >
 > anyway .... or that is what it looks like to me .... so it looks likes the
 > system makes that definition by
 > default (in which case there is no need to define it manually in the source
 > code).
 
 Only if you are compiling in C++11 mode (most compilers don't use this
 mode except when it is specifically requested, because it is so new,
 and is rarely fully supported).  The  is because the requirement that
 some of these standard C definitions be hidden from C++ code except
 when __STDC_LIMIT_MACROS and/or  __STDC_CONSTANT_MACROS is/are defined
 was removed from the C11 standard, and an explicit note was added to
 the C++11 standard  that the __STDC* macros are not to be considered
 when including <cstdint>, so some implementations have taken this as
 license to disregard them entirely in C++11 mode:
 
 http://svnweb.FreeBSD.org/base?view=revision&amp;revision=227475
 http://svnweb.FreeBSD.org/base?view=revision&amp;revision=227478
 
 I don't have a live system running FreeBSD 9*, but on -CURRENT a
 simple program like:
 
 #include <stdint.h>
 
 #ifdef UINT64_MAX
 #error UINT64_MAX is defined
 #else
 #error UINT64_MAX isn't defined
 #endif
 
 int main(void)
 {
 return (0);
 }
 
 behaves as expected:
 
 # c++ -Wall -Wextra -std=c++98 -o t1 test1.cc
 test1.cc:6:2: error: UINT64_MAX isn't defined
 #error UINT64_MAX isn't defined
  ^
 1 error generated.
 ret 1
 # c++ -Wall -Wextra -std=c++98 -D__STDC_LIMIT_MACROS -o t1 test1.cc
 test1.cc:4:2: error: UINT64_MAX is defined
 #error UINT64_MAX is defined
  ^
 1 error generated.
 ret 1
 # c++ -Wall -Wextra -std=c++11 -o t1 test1.cc
 test1.cc:4:2: error: UINT64_MAX is defined
 #error UINT64_MAX is defined
  ^
 1 error generated.
 ret 1
 
 Also, in 9.1, I see in src/sys/sys/stdint.h (installed as
 /usr/include/stdint.h):
 
 35#include <machine/_stdint.h>
 
 and in the machine-dependent headers -- for example, in
 src/sys/i386/include/_stdint.h
 , which is installed as /usr/include/machine/_stdint.h on i386(on
 -CURRENT there is one more remove, because some of the i386 and amd64
 headers have been unified):
 
 60#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
 ...
 82#define UINT64_MAX      0xffffffffffffffffULL
 
 So are you sure you haven't overlooked something?
 
 b.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212262110.qBQLA1C6076762>